151
|
1 using System;
|
|
2 using System.Runtime.CompilerServices;
|
|
3
|
|
4 namespace Implab {
|
|
5 public struct PromiseAwaiter : INotifyCompletion {
|
|
6 readonly IPromise m_promise;
|
|
7
|
|
8 public PromiseAwaiter(IPromise 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 void GetResult() {
|
|
18 m_promise.Join();
|
|
19 }
|
|
20
|
|
21 public bool IsCompleted {
|
|
22 get {
|
|
23 return m_promise.IsResolved;
|
|
24 }
|
|
25 }
|
|
26 }
|
|
27 }
|
|
28
|