public TestConsumer(AsyncBarrier barrier = null) { Action = async cancellationToken => { using (Inbox) { await foreach (var item in Inbox.ReadAllAsync(cancellationToken)) { Values.Add(item); if (barrier != null) { await barrier.SignalAndWait(); } } } }; Start(); }
internal static async IAsyncEnumerable <Producer <T> > CreateMany <T>(IEnumerable <T> data, int count, AsyncBarrier barrier = null) { for (int i = 0; i < count; ++i) { yield return(data.AsProducer(barrier).Outbox); await Task.Delay(0); } }
internal static TestProducer <T> AsProducer <T>(this IEnumerable <T> data, AsyncBarrier barrier = null) => new TestProducer <T>(data, barrier);