Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ReadAsync()

override ValueTask< T > System.Threading.Channels.SingleConsumerUnboundedChannel< T >.UnboundedChannelReader.ReadAsync ( CancellationToken cancellationToken)
inlinevirtual

Reimplemented from System.Threading.Channels.ChannelReader< T >.

Definition at line 36 of file SingleConsumerUnboundedChannel.cs.

37 {
38 if (cancellationToken.IsCancellationRequested)
39 {
41 }
42 if (TryRead(out var item))
43 {
44 return new ValueTask<T>(item);
45 }
49 lock (parent.SyncObj)
50 {
51 if (TryRead(out item))
52 {
53 return new ValueTask<T>(item);
54 }
55 if (parent._doneWriting != null)
56 {
57 return ChannelUtilities.GetInvalidCompletionValueTask<T>(parent._doneWriting);
58 }
59 asyncOperation = parent._blockedReader;
61 {
64 {
65 asyncOperation = null;
66 }
67 }
68 else
69 {
70 asyncOperation2 = new AsyncOperation<T>(_parent._runContinuationsAsynchronously, cancellationToken);
71 }
72 parent._blockedReader = asyncOperation2;
73 }
74 asyncOperation?.TrySetCanceled();
75 return asyncOperation2.ValueTaskOfT;
76 }
static Task FromCanceled(CancellationToken cancellationToken)
Definition Task.cs:3363

References System.Threading.Channels.SingleConsumerUnboundedChannel< T >.UnboundedChannelReader._parent, System.Threading.Channels.SingleConsumerUnboundedChannel< T >.UnboundedChannelReader._readerSingleton, System.cancellationToken, System.Threading.Tasks.Task< TResult >.FromCanceled(), System.item, System.Threading.Channels.AsyncOperation< TResult >.TryOwnAndReset(), and System.Threading.Channels.SingleConsumerUnboundedChannel< T >.UnboundedChannelReader.TryRead().