annotate Implab/FuncChainTaskT.cs @ 145:706fccb85524 v2

RC: cancellation support for promises + tests
author cin
date Sun, 08 Mar 2015 02:52:27 +0300
parents
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 FuncChainTask<TArg,TResult> : FuncChainTaskBase<TResult>, IDeferred<TArg> {
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
5 readonly Func<TArg, IPromise<TResult>> 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 FuncChainTask(Func<TArg, IPromise<TResult>> task, Func<Exception, IPromise<TResult>> error, Func<Exception, IPromise<TResult>> 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(TArg 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 }