Mercurial > pub > ImplabNet
annotate Implab/Promise.cs @ 203:4d9830a9bbb8 v2
Added 'Fail' method to RunnableComponent which allows component to move from
Running to Failed state.
Added PollingComponent a timer based runnable component
More tests
Added FailPromise a thin class to wrap exceptions
Fixed error handling in SuccessPromise classes.
author | cin |
---|---|
date | Tue, 18 Oct 2016 17:49:54 +0300 |
parents | 8c0b95069066 |
children | 8200ab154c8a |
rev | line source |
---|---|
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
1 using System; |
144 | 2 using Implab.Parallels; |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
3 |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
4 namespace Implab { |
144 | 5 public class Promise : AbstractPromise, IDeferred { |
6 public static readonly Promise SUCCESS; | |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
7 |
144 | 8 static Promise() { |
9 SUCCESS = new Promise(); | |
10 SUCCESS.Resolve(); | |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
11 } |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
12 |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
13 public void Resolve() { |
144 | 14 SetResult(); |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
15 } |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
16 |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
17 public void Reject(Exception error) { |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
18 SetError(error); |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
19 } |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
20 } |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
21 } |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
22 |