annotate Implab/ActionChainTaskT.cs @ 147:25cdef49102f v2

sync
author cin
date Tue, 17 Mar 2015 08:25:35 +0300
parents 706fccb85524
children eb793fbbe4ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
1 using System;
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
2
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
3 namespace Implab {
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
4 public class ActionChainTask<T> : ActionChainTaskBase, IDeferred<T> {
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
5 readonly Func<T, IPromise> m_task;
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
6
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
7 public ActionChainTask(Func<T, IPromise> task, Func<Exception, IPromise> error, Func<Exception, IPromise> cancel) : base(error,cancel) {
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
8 m_task = task;
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
9 }
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
10
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
11 public void Resolve(T value) {
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
12 if (m_task != null && LockCancelation()) {
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
13 try {
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
14 Observe(m_task(value));
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
15 } catch(Exception err) {
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
16 HandleErrorInternal(err);
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
17 }
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
18 }
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
19 }
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
20
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
21 }
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
22 }
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
23