annotate Implab/SyncContextPromise.cs @ 141:0fa293bb1351 v2

fixed JSON writer
author cin
date Tue, 24 Feb 2015 00:54:22 +0300
parents f75cfa58e3d4
children 706fccb85524
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;
138
f75cfa58e3d4 added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents: 119
diff changeset
2 using System;
72
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
3
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
4 namespace Implab {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
5 public class SyncContextPromise<T> : Promise<T> {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
6 readonly SynchronizationContext m_context;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
7
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
8 public SyncContextPromise(SynchronizationContext context) {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
9 Safe.ArgumentNotNull(context, "context");
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
10 m_context = context;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
11 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
12
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
13 protected override void SignalSuccess(IDeferred<T> handler) {
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
14 m_context.Post(x => base.SignalSuccess(handler), null);
72
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
15 }
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
16
138
f75cfa58e3d4 added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents: 119
diff changeset
17 protected override void SignalError(IDeferred<T> handler, Exception error) {
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 106
diff changeset
18 m_context.Post(x => base.SignalError(handler, error), null);
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
138
f75cfa58e3d4 added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents: 119
diff changeset
21 protected override void SignalCancelled(IDeferred<T> handler, Exception reason) {
f75cfa58e3d4 added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents: 119
diff changeset
22 m_context.Post(x => base.SignalCancelled(handler, reason), null);
72
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
23 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
24 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
25 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
26