Mercurial > pub > ImplabNet
annotate Implab/Promise.cs @ 210:5dc21f6a3222 v2
Code review for RunnableComponent
Added StaApartment class based on System.Windows.Forms.Application message loop
author | cin |
---|---|
date | Mon, 20 Mar 2017 17:44:18 +0300 |
parents | 8200ab154c8a |
children | b1e0ffdf3451 |
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 { |
205
8200ab154c8a
Added ResetState to RunnableComponent to reset in case of failure
cin
parents:
144
diff
changeset
|
6 public static readonly IPromise Success; |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
7 |
144 | 8 static Promise() { |
205
8200ab154c8a
Added ResetState to RunnableComponent to reset in case of failure
cin
parents:
144
diff
changeset
|
9 Success = new SuccessPromise(); |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
10 } |
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 public void Resolve() { |
144 | 13 SetResult(); |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
14 } |
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 public void Reject(Exception error) { |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
17 SetError(error); |
205
8200ab154c8a
Added ResetState to RunnableComponent to reset in case of failure
cin
parents:
144
diff
changeset
|
18 } |
8200ab154c8a
Added ResetState to RunnableComponent to reset in case of failure
cin
parents:
144
diff
changeset
|
19 |
8200ab154c8a
Added ResetState to RunnableComponent to reset in case of failure
cin
parents:
144
diff
changeset
|
20 public static IPromise FromException(Exception exception) { |
8200ab154c8a
Added ResetState to RunnableComponent to reset in case of failure
cin
parents:
144
diff
changeset
|
21 return new FailedPromise(exception); |
8200ab154c8a
Added ResetState to RunnableComponent to reset in case of failure
cin
parents:
144
diff
changeset
|
22 } |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
23 } |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
24 } |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
112
diff
changeset
|
25 |