Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RendezvousAwaitable.cs
Go to the documentation of this file.
3
5
7{
8 private static readonly Action s_completionSentinel = delegate
9 {
10 };
11
12 private Action _continuation;
13
15
17
18 public bool RunContinuationsAsynchronously { get; set; } = true;
19
20
21 public bool IsCompleted
22 {
23 get
24 {
25 Action action = Volatile.Read(ref _continuation);
26 return action != null;
27 }
28 }
29
31 {
32 return this;
33 }
34
36 {
37 _continuation = null;
39 if (error != null)
40 {
41 _error = null;
42 error.Throw();
43 }
44 TResult result = _result;
45 _result = default(TResult);
46 return result;
47 }
48
49 public void SetResult(TResult result)
50 {
51 _result = result;
53 }
54
55 private void NotifyAwaiter()
56 {
58 if (action != null)
59 {
61 {
63 }
64 else
65 {
66 action();
67 }
68 }
69 }
70
71 public void OnCompleted(Action continuation)
72 {
73 Action action = _continuation ?? Interlocked.CompareExchange(ref _continuation, continuation, null);
74 if (action != null)
75 {
76 Task.Run(continuation);
77 }
78 }
79
80 public void UnsafeOnCompleted(Action continuation)
81 {
82 OnCompleted(continuation);
83 }
84}
static int CompareExchange(ref int location1, int value, int comparand)
RendezvousAwaitable< TResult > GetAwaiter()
static Task Run(Action action)
Definition Task.cs:3395
static bool Read(ref bool location)
Definition Volatile.cs:67