annotate Implab/SyncContextPromise.cs @ 119:2573b562e328 v2

Promises rewritten, added improved version of AsyncQueue
author cin
date Sun, 11 Jan 2015 19:13:02 +0300
parents d4e38929ce36
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