SkillAgentSearch skills...

AsyncEnumerableSource

No description available

Install / Use

/learn @RoyalScribblz/AsyncEnumerableSource
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

AsyncEnumerableSource

.NET language OS GitHub last commit

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.

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 ReaderWriterLockSlim and Interlocked.
  • 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)

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.

View on GitHub
GitHub Stars22
CategoryDevelopment
Updated11mo ago
Forks0

Languages

C#

Security Score

77/100

Audited on May 6, 2025

No findings