annotate Implab/SyncContextPromise.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 97fbbf816844
children 3eb3255d8cc5
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
156
97fbbf816844 Promises: SignalXXX methods merged into SignalHandler method.
cin
parents: 145
diff changeset
13 protected override void SignalHandler(HandlerDescriptor handler, int signal) {
97fbbf816844 Promises: SignalXXX methods merged into SignalHandler method.
cin
parents: 145
diff changeset
14 m_context.Post(x => base.SignalHandler(handler, signal), null);
72
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
15 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
16 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
17 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
18