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

◆ ReadAsync()

override ValueTask< T > System.Threading.Channels.BoundedChannel< T >.BoundedChannelReader.ReadAsync ( CancellationToken cancellationToken)
inlinevirtual

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

Definition at line 79 of file BoundedChannel.cs.

80 {
81 if (cancellationToken.IsCancellationRequested)
82 {
84 }
86 lock (parent.SyncObj)
87 {
88 if (!parent._items.IsEmpty)
89 {
91 }
92 if (parent._doneWriting != null)
93 {
94 return ChannelUtilities.GetInvalidCompletionValueTask<T>(parent._doneWriting);
95 }
96 if (!cancellationToken.CanBeCanceled)
97 {
99 if (readerSingleton.TryOwnAndReset())
100 {
101 parent._blockedReaders.EnqueueTail(readerSingleton);
102 return readerSingleton.ValueTaskOfT;
103 }
104 }
105 AsyncOperation<T> asyncOperation = new AsyncOperation<T>(parent._runContinuationsAsynchronously | cancellationToken.CanBeCanceled, cancellationToken);
106 parent._blockedReaders.EnqueueTail(asyncOperation);
107 return asyncOperation.ValueTaskOfT;
108 }
109 }
static Task FromCanceled(CancellationToken cancellationToken)
Definition Task.cs:3363

References System.Threading.Channels.BoundedChannel< T >.BoundedChannelReader._parent, System.Threading.Channels.BoundedChannel< T >.BoundedChannelReader._readerSingleton, System.cancellationToken, System.Threading.Channels.BoundedChannel< T >.BoundedChannelReader.DequeueItemAndPostProcess(), and System.Threading.Tasks.Task< TResult >.FromCanceled().