This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net5.0</TargetFramework> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Elasticsearch.Net" Version="7.10.0" /> | |
</ItemGroup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public virtual async IAsyncEnumerable<T> ReadAllAsync([EnumeratorCancellation] CancellationToken cancellationToken = default) | |
{ | |
while (await WaitToReadAsync(cancellationToken).ConfigureAwait(false)) | |
{ | |
while (TryRead(out T item)) | |
{ | |
yield return item; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var waiter = new AsyncOperation<bool>(parent._runContinuationsAsynchronously, cancellationToken); | |
ChannelUtilities.QueueWaiter(ref parent._waitingReadersTail, waiter); | |
return waiter.ValueTaskOfT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!cancellationToken.CanBeCanceled) | |
{ | |
AsyncOperation<bool> singleton = _waiterSingleton; | |
if (singleton.TryOwnAndReset()) | |
{ | |
ChannelUtilities.QueueWaiter(ref parent._waitingReadersTail, singleton); | |
return singleton.ValueTaskOfT; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (parent._doneWriting != null) | |
{ | |
return parent._doneWriting != ChannelUtilities.s_doneWritingSentinel ? | |
new ValueTask<bool>(Task.FromException<bool>(parent._doneWriting)) : | |
default; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UnboundedChannel<T> parent = _parent; | |
lock (parent.SyncObj) | |
{ | |
parent.AssertInvariants(); | |
// Try again to read now that we're synchronized with writers. | |
if (!parent._items.IsEmpty) | |
{ | |
return new ValueTask<bool>(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (cancellationToken.IsCancellationRequested) | |
{ | |
return new ValueTask<bool>(Task.FromCanceled<bool>(cancellationToken)); | |
} | |
if (!_parent._items.IsEmpty) | |
{ | |
return new ValueTask<bool>(true); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override bool TryRead([MaybeNullWhen(false)] out T item) | |
{ | |
UnboundedChannel<T> parent = _parent; | |
// Dequeue an item if we can | |
if (parent._items.TryDequeue(out item)) | |
{ | |
CompleteIfDone(parent); | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var reader = new AsyncOperation<T>(parent._runContinuationsAsynchronously, cancellationToken); | |
parent._blockedReaders.EnqueueTail(reader); | |
return reader.ValueTaskOfT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!cancellationToken.CanBeCanceled) | |
{ | |
AsyncOperation<T> singleton = _readerSingleton; | |
if (singleton.TryOwnAndReset()) | |
{ | |
parent._blockedReaders.EnqueueTail(singleton); | |
return singleton.ValueTaskOfT; | |
} | |
} |
NewerOlder