9[DebuggerDisplay(
"Items={ItemsCountForDebugger}, Closed={ChannelIsClosedForDebugger}")]
13 [DebuggerDisplay(
"Items={Count}")]
45 if (parent._items.TryDequeue(
out var result))
52 if (parent._items.TryDequeue(
out result))
57 if (parent._doneWriting !=
null)
59 return ChannelUtilities.GetInvalidCompletionValueTask<T>(parent._doneWriting);
79 if (parent._items.TryDequeue(
out item))
95 if (parent._doneWriting !=
null && parent._items.IsEmpty)
112 lock (parent.SyncObj)
114 if (!parent._items.IsEmpty)
118 if (parent._doneWriting !=
null)
143 [DebuggerDisplay(
"Items={ItemsCountForDebugger}")]
160 lock (parent.SyncObj)
162 if (parent._doneWriting !=
null)
167 isEmpty = parent._items.IsEmpty;
186 lock (parent.SyncObj)
188 if (parent._doneWriting !=
null)
192 if (parent._blockedReaders.IsEmpty)
194 parent._items.Enqueue(
item);
195 listTail = parent._waitingReadersTail;
200 parent._waitingReadersTail =
null;
Enumerator GetEnumerator()
static void QueueWaiter(ref AsyncOperation< bool > tail, AsyncOperation< bool > waiter)
static readonly Exception s_doneWritingSentinel
static void Complete(TaskCompletionSource tcs, Exception error=null)
static void WakeUpWaiters(ref AsyncOperation< bool > listTail, bool result, Exception error=null)
static Exception CreateInvalidCompletionException(Exception inner=null)
override ValueTask< bool > WaitToReadAsync(CancellationToken cancellationToken)
override bool TryRead([MaybeNullWhen(false)] out T item)
readonly AsyncOperation< T > _readerSingleton
UnboundedChannelReader(UnboundedChannel< T > parent)
override ValueTask< T > ReadAsync(CancellationToken cancellationToken)
override bool TryPeek([MaybeNullWhen(false)] out T item)
readonly UnboundedChannel< T > _parent
readonly AsyncOperation< bool > _waiterSingleton
void CompleteIfDone(UnboundedChannel< T > parent)
override bool TryComplete(Exception error)
override ValueTask< bool > WaitToWriteAsync(CancellationToken cancellationToken)
override bool TryWrite(T item)
override ValueTask WriteAsync(T item, CancellationToken cancellationToken)
UnboundedChannelWriter(UnboundedChannel< T > parent)
int ItemsCountForDebugger
readonly UnboundedChannel< T > _parent
readonly Deque< AsyncOperation< T > > _blockedReaders
readonly TaskCompletionSource _completion
AsyncOperation< bool > _waitingReadersTail
int ItemsCountForDebugger
bool ChannelIsClosedForDebugger
readonly ConcurrentQueue< T > _items
readonly bool _runContinuationsAsynchronously
UnboundedChannel(bool runContinuationsAsynchronously)
static Task FromException(Exception exception)
static Task FromCanceled(CancellationToken cancellationToken)