248
|
1 using System;
|
|
2
|
|
3 namespace Implab {
|
|
4 public struct ResolvedPromise<T> : IPromise<T> {
|
|
5 T m_result;
|
|
6
|
|
7 public Type ResultType => typeof(T);
|
|
8
|
|
9 public bool IsResolved => true;
|
|
10
|
|
11 public bool IsRejected => false;
|
|
12
|
|
13 public bool IsFulfilled => true;
|
|
14
|
|
15 public Exception RejectReason => null;
|
|
16
|
|
17 public ResolvedPromise(T result) {
|
|
18 m_result = result;
|
|
19 }
|
|
20
|
|
21 public IPromise<T2> Cast<T2>() {
|
|
22 return (IPromise<T2>)(IPromise<T>)this;
|
|
23 }
|
|
24
|
|
25 void IPromise.Join() {
|
|
26 }
|
|
27
|
|
28 void IPromise.Join(int timeout) {
|
|
29 }
|
|
30
|
|
31 public T Join() {
|
|
32 return m_result;
|
|
33 }
|
|
34
|
|
35 public T Join(int timeout) {
|
|
36 return m_result;
|
|
37 }
|
|
38
|
|
39 public void Then(IResolvable<T> next) {
|
|
40 next.Resolve(m_result);
|
|
41 }
|
|
42
|
|
43 public void Then(IResolvable next) {
|
|
44 next.Resolve();
|
|
45 }
|
|
46 }
|
|
47 } |