annotate Implab/ResolvedPromise`1.cs @ 267:6b3e5c48131b v3

Working on Unity xml configuration
author cin
date Fri, 20 Apr 2018 19:05:12 +0300
parents 5cb4826c2c2a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
248
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
1 using System;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
2
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
3 namespace Implab {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
4 public struct ResolvedPromise<T> : IPromise<T> {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
5 T m_result;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
6
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
7 public Type ResultType => typeof(T);
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
8
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
9 public bool IsResolved => true;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
10
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
11 public bool IsRejected => false;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
12
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
13 public bool IsFulfilled => true;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
14
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
15 public Exception RejectReason => null;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
16
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
17 public ResolvedPromise(T result) {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
18 m_result = result;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
19 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
20
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
21 public IPromise<T2> Cast<T2>() {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
22 return (IPromise<T2>)(IPromise<T>)this;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
23 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
24
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
25 void IPromise.Join() {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
26 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
27
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
28 void IPromise.Join(int timeout) {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
29 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
30
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
31 public T Join() {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
32 return m_result;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
33 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
34
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
35 public T Join(int timeout) {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
36 return m_result;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
37 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
38
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
39 public void Then(IResolvable<T> next) {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
40 next.Resolve(m_result);
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
41 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
42
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
43 public void Then(IResolvable next) {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
44 next.Resolve();
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
45 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
46 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
47 }