annotate Implab/PromiseReaction`1.cs @ 246:5aa9cfbe56c3 v3

missing files
author cin
date Fri, 26 Jan 2018 11:19:38 +0300
parents
children fb70574741a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
246
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
1 using System;
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
2
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
3 namespace Implab {
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
4 public class PromiseReaction<T> : IResolvable<T> {
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
5 IDispatcher m_dispatcher;
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
6
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
7 Action<T> m_onFulfilledJob;
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
8
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
9 Action<Exception> m_onRejectedJob;
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
10
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
11 public void Reject(Exception error) {
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
12 if (m_dispatcher != null)
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
13 m_dispatcher.Enqueue(() => m_onRejectedJob(error));
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
14 else
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
15 m_onRejectedJob(error);
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
16 }
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
17
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
18 public void Resolve(T result) {
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
19 if (m_dispatcher != null)
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
20 m_dispatcher.Enqueue(() => m_onFulfilledJob(result));
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
21 else
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
22 m_onFulfilledJob(result);
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
23 }
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
24 }
5aa9cfbe56c3 missing files
cin
parents:
diff changeset
25 }