comparison Implab/RejectedPromise.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 d82909310094
comparison
equal deleted inserted replaced
247:fb70574741a1 248:5cb4826c2c2a
1 using System;
2
3 namespace Implab
4 {
5 public struct RejectedPromise : IPromise {
6 readonly Exception m_reason;
7
8 public Type ResultType => typeof(void);
9
10 public bool IsResolved => true;
11
12 public bool IsRejected => true;
13
14 public bool IsFulfilled => false;
15
16 public Exception RejectReason => m_reason;
17
18 public RejectedPromise(Exception reason) {
19 m_reason = reason;
20 }
21
22 public IPromise<T> Cast<T>() {
23 throw new InvalidCastException();
24 }
25
26 public void Join() {
27 m_reason.ThrowInvocationException();
28 }
29
30 public void Join(int timeout) {
31 m_reason.ThrowInvocationException();
32 }
33
34 public void Then(IResolvable next) {
35 next.Reject(m_reason);
36 }
37 }
38 }