Mercurial > pub > ImplabNet
comparison Implab/Promise.cs @ 205:8200ab154c8a v2
Added ResetState to RunnableComponent to reset in case of failure
Added StateChanged event to IRunnable
Renamed Promise.SUCCESS -> Promise.Success
Added Promise.FromException
Renamed Bundle -> PromiseAll in PromiseExtensions
| author | cin |
|---|---|
| date | Tue, 25 Oct 2016 17:40:33 +0300 |
| parents | 8c0b95069066 |
| children | b1e0ffdf3451 |
comparison
equal
deleted
inserted
replaced
| 203:4d9830a9bbb8 | 205:8200ab154c8a |
|---|---|
| 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, IDeferred { |
| 6 public static readonly Promise SUCCESS; | 6 public static readonly IPromise Success; |
| 7 | 7 |
| 8 static Promise() { | 8 static Promise() { |
| 9 SUCCESS = new Promise(); | 9 Success = new SuccessPromise(); |
| 10 SUCCESS.Resolve(); | |
| 11 } | 10 } |
| 12 | 11 |
| 13 public void Resolve() { | 12 public void Resolve() { |
| 14 SetResult(); | 13 SetResult(); |
| 15 } | 14 } |
| 16 | 15 |
| 17 public void Reject(Exception error) { | 16 public void Reject(Exception error) { |
| 18 SetError(error); | 17 SetError(error); |
| 19 } | 18 } |
| 19 | |
| 20 public static IPromise FromException(Exception exception) { | |
| 21 return new FailedPromise(exception); | |
| 22 } | |
| 20 } | 23 } |
| 21 } | 24 } |
| 22 | 25 |
