annotate Implab/SyncContextPromise.cs @ 130:671f60cd0250 v2

fixed Resove method bug when calling it on already cancelled promise
author cin
date Fri, 30 Jan 2015 17:07:17 +0300
parents 2573b562e328
children f75cfa58e3d4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
1 using System.Threading;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
2
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
3 namespace Implab {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
4 public class SyncContextPromise<T> : Promise<T> {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
5 readonly SynchronizationContext m_context;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
6
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
7 public SyncContextPromise(SynchronizationContext context) {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
8 Safe.ArgumentNotNull(context, "context");
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
9 m_context = context;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
10 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
11
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
12 protected override void SignalSuccess(IDeferred<T> handler) {
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
13 m_context.Post(x => base.SignalSuccess(handler), null);
72
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
14 }
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
15
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
16 protected override void SignalError(IDeferred<T> handler, System.Exception error) {
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
17 m_context.Post(x => base.SignalError(handler, error), null);
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
18 }
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
19
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
20 protected override void SignalCancelled(IDeferred<T> handler) {
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
21 m_context.Post(x => base.SignalCancelled(handler), null);
72
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
22 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
23 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
24 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
25