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

◆ WaitToWriteAsync()

override ValueTask< bool > System.Threading.Channels.BoundedChannel< T >.BoundedChannelWriter.WaitToWriteAsync ( CancellationToken cancellationToken)
inline

Definition at line 298 of file BoundedChannel.cs.

299 {
300 if (cancellationToken.IsCancellationRequested)
301 {
303 }
304 BoundedChannel<T> parent = _parent;
305 lock (parent.SyncObj)
306 {
307 if (parent._doneWriting != null)
308 {
309 return (parent._doneWriting != ChannelUtilities.s_doneWritingSentinel) ? new ValueTask<bool>(Task.FromException<bool>(parent._doneWriting)) : default(ValueTask<bool>);
310 }
311 if (parent._items.Count < parent._bufferedCapacity || parent._mode != 0)
312 {
313 return new ValueTask<bool>(result: true);
314 }
315 if (!cancellationToken.CanBeCanceled)
316 {
318 if (waiterSingleton.TryOwnAndReset())
319 {
320 ChannelUtilities.QueueWaiter(ref parent._waitingWritersTail, waiterSingleton);
321 return waiterSingleton.ValueTaskOfT;
322 }
323 }
325 ChannelUtilities.QueueWaiter(ref parent._waitingWritersTail, asyncOperation);
326 return asyncOperation.ValueTaskOfT;
327 }
328 }
static Task FromException(Exception exception)
Definition Task.cs:3341
static Task FromCanceled(CancellationToken cancellationToken)
Definition Task.cs:3363

References System.Threading.Channels.BoundedChannel< T >.BoundedChannelWriter._parent, System.Threading.Channels.BoundedChannel< T >.BoundedChannelWriter._waiterSingleton, System.cancellationToken, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Threading.Tasks.Task< TResult >.FromCanceled(), System.Threading.Tasks.Task< TResult >.FromException(), System.Threading.Channels.ChannelUtilities.QueueWaiter(), and System.Threading.Channels.ChannelUtilities.s_doneWritingSentinel.