Method ToBoundedChannel
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Channel.dll
ToBoundedChannel<T>(IMappedQuery<T>, int, CancellationToken)
Reads the query into a new bounded channel and returns the channel.
public static Channel<T> ToBoundedChannel<T>(this IMappedQuery<T> source, int capacity, CancellationToken cancellationToken = default)
Parameters
sourceIMappedQuery<T>The mapped query to read.
capacityintThe most rows the channel holds.
cancellationTokenCancellationTokenCancels the read.
Returns
- Channel<T>
The new channel.
Type Parameters
TThe type of each row.
Remarks
The bound limits the channel, not memory: the query is still read at full speed, and the rows the channel has no room for wait in an internal queue.
Exceptions
- ArgumentNullException
sourceis null.- ArgumentOutOfRangeException
capacityis less than one.- OperationCanceledException
cancellationTokenis already canceled.