151
|
1 using System;
|
|
2 using System.Runtime.CompilerServices;
|
|
3
|
|
4 namespace Implab {
|
|
5 public struct PromiseAwaiter<T> : INotifyCompletion {
|
|
6 readonly IPromise<T> m_promise;
|
|
7
|
|
8 public PromiseAwaiter(IPromise<T> promise) {
|
|
9 m_promise = promise;
|
|
10 }
|
|
11
|
|
12 public void OnCompleted (Action continuation) {
|
|
13 if (m_promise != null)
|
|
14 m_promise.On(continuation, PromiseEventType.All);
|
|
15 }
|
|
16
|
|
17 public T GetResult() {
|
|
18 return m_promise.Join();
|
|
19 }
|
|
20
|
|
21 public bool IsCompleted {
|
|
22 get {
|
242
|
23 return m_promise.IsFulfilled;
|
151
|
24 }
|
|
25 }
|
|
26 }
|
|
27 }
|
|
28
|