Mercurial > pub > ImplabNet
comparison Implab/Promise.cs @ 243:b1e0ffdf3451 v3
working on promises
author | cin |
---|---|
date | Wed, 24 Jan 2018 19:24:10 +0300 |
parents | 8200ab154c8a |
children |
comparison
equal
deleted
inserted
replaced
242:cbe10ac0731e | 243:b1e0ffdf3451 |
---|---|
1 using System; | 1 using System; |
2 using Implab.Parallels; | 2 using Implab.Parallels; |
3 | 3 |
4 namespace Implab { | 4 namespace Implab { |
5 public class Promise : AbstractPromise, IDeferred { | 5 public class Promise : AbstractPromise { |
6 public static readonly IPromise Success; | 6 public static readonly IPromise Success; |
7 | 7 |
8 static Promise() { | 8 static Promise() { |
9 Success = new SuccessPromise(); | 9 Success = new SuccessPromise(); |
10 } | 10 } |
11 | 11 |
12 public void Resolve() { | 12 internal void ResolvePromise() { |
13 SetResult(); | 13 SetResult(); |
14 } | 14 } |
15 | 15 |
16 public void Reject(Exception error) { | 16 internal void RejectPromise(Exception error) { |
17 SetError(error); | 17 SetError(error); |
18 } | 18 } |
19 | 19 |
20 public static IPromise FromException(Exception exception) { | 20 public static IPromise Reject(Exception exception) { |
21 return new FailedPromise(exception); | 21 return new FailedPromise(exception); |
22 } | 22 } |
23 } | 23 } |
24 } | 24 } |
25 | 25 |