comparison Implab/ResolvedPromise`1.cs @ 248:5cb4826c2c2a v3

Added awaiters to promises Added static methods to Promise Resolve, Reject, All. Updated promise helpers
author cin
date Tue, 30 Jan 2018 01:37:17 +0300
parents
children
comparison
equal deleted inserted replaced
247:fb70574741a1 248:5cb4826c2c2a
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 }