AsyncEnumerableSource 2.0.0
dotnet add package AsyncEnumerableSource --version 2.0.0
NuGet\Install-Package AsyncEnumerableSource -Version 2.0.0
<PackageReference Include="AsyncEnumerableSource" Version="2.0.0" />
<PackageVersion Include="AsyncEnumerableSource" Version="2.0.0" />
<PackageReference Include="AsyncEnumerableSource" />
paket add AsyncEnumerableSource --version 2.0.0
#r "nuget: AsyncEnumerableSource, 2.0.0"
#:package AsyncEnumerableSource@2.0.0
#addin nuget:?package=AsyncEnumerableSource&version=2.0.0
#tool nuget:?package=AsyncEnumerableSource&version=2.0.0
AsyncEnumerableSource
Overview
AsyncEnumerableSource<T> is a high-performance, thread-safe asynchronous enumerable source designed to facilitate
multiple consumers of a data stream. This implementation leverages System.Threading.Channels to efficiently handle
asynchronous data production and consumption.
Version 2.x targets .NET 10. Use the 1.3.x line for older target frameworks.
Features
- Supports multiple consumers subscribing to an asynchronous data stream.
- Provides methods for safely yielding items to all consumers.
- Supports completion and faulting of the data stream.
- Thread-safe implementation with
ReaderWriterLockSlimandInterlocked. - Optimized for scalability with parallel processing when necessary.
Installation
dotnet add package AsyncEnumerableSource
Usage
Creating an Async Enumerable Source
var source = new AsyncEnumerableSource<T>();
Consuming Data Asynchronously
await foreach (var item in source.GetAsyncEnumerable())
{
Console.WriteLine(item);
}
Producing Data
source.YieldReturn(value)
For batch yielding:
await source.YieldReturn(values);
For asynchronous batch yielding:
await source.YieldReturn(asyncValues);
Completing the Source
source.Complete();
Handling Errors
If an exception occurs and should propagate to all consumers:
source.Fault(new Exception());
Benchmarks
Benchmarks are included using BenchmarkDotNet. Results can be found in the artifacts of the GitHub Actions runs. To run the benchmarks yourself, run the following command:
dotnet run -c Release --project AsyncEnumerableSource.Benchmarks
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please submit issues and pull requests as needed.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.