/// <summary> /// Pipes the source data through a single producer constrained TransformBlock with the specified bounded capacity. /// </summary> /// <typeparam name="TIn">The input type.</typeparam> /// <typeparam name="TOut">The output type.</typeparam> /// <param name="source">The source block to receive from.</param> /// <param name="capacity">The bounded capacity of the transform block</param> /// <param name="transform">The transform function to apply.</param> /// <param name="cancellationToken">An optional cancellation token.</param> /// <returns>The TransformBlock created.</returns> public static IReceivableSourceBlock <TOut> PipeLimited <TIn, TOut>(this ISourceBlock <TIn> source, int capacity, Func <TIn, TOut> transform, CancellationToken cancellationToken = default) => source.Pipe(transform, new ExecutionDataflowBlockOptions { BoundedCapacity = capacity, SingleProducerConstrained = true, CancellationToken = cancellationToken });
/// <summary> /// Pipes the source data through a single producer constrained TransformBlock with the specified bounded capacity and max concurrency. /// </summary> /// <typeparam name="TIn">The input type.</typeparam> /// <typeparam name="TOut">The output type.</typeparam> /// <param name="source">The source block to receive from.</param> /// <param name="capacity">The bounded capacity of the transform block</param> /// <param name="maxConcurrency">The maximum concurrency of the transform block</param> /// <param name="transform">The transform function to apply.</param> /// <param name="cancellationToken">An optional cancellation token.</param> /// <returns>The TransformBlock created.</returns> public static IReceivableSourceBlock <TOut> Pipe <TIn, TOut>(this ISourceBlock <TIn> source, int capacity, int maxConcurrency, Func <TIn, TOut> transform, CancellationToken cancellationToken = default) => source.Pipe(transform, new ExecutionDataflowBlockOptions { BoundedCapacity = capacity, MaxDegreeOfParallelism = maxConcurrency, SingleProducerConstrained = true, CancellationToken = cancellationToken });
/// <summary> /// Pipes the source data through a single producer constrained ActionBlock with the specified bounded capacity. /// </summary> /// <typeparam name="T">The input type.</typeparam> /// <param name="source">The source block to receive from.</param> /// <param name="capacity">The bounded capacity of the transform block</param> /// <param name="handler">The handler function to apply.</param> /// <param name="cancellationToken">An optional cancellation token.</param> /// <returns>The ActionBlock created.</returns> public static ActionBlock <T> PipeLimited <T>(this ISourceBlock <T> source, int capacity, Action <T> handler, CancellationToken cancellationToken = default) => source.Pipe(handler, new ExecutionDataflowBlockOptions { BoundedCapacity = capacity, SingleProducerConstrained = true, CancellationToken = cancellationToken });
/// <summary> /// Pipes the source data through a single producer constrained ActionBlock with the specified bounded capacity and max concurrency. /// </summary> /// <typeparam name="T">The input type.</typeparam> /// <param name="source">The source block to receive from.</param> /// <param name="capacity">The bounded capacity of the transform block</param> /// <param name="maxConcurrency">The maximum concurrency of the action block</param> /// <param name="handler">The handler function to apply.</param> /// <param name="cancellationToken">An optional cancellation token.</param> /// <returns>The ActionBlock created.</returns> public static ActionBlock <T> Pipe <T>(this ISourceBlock <T> source, int capacity, int maxConcurrency, Action <T> handler, CancellationToken cancellationToken = default) => source.Pipe(handler, new ExecutionDataflowBlockOptions { BoundedCapacity = capacity, MaxDegreeOfParallelism = maxConcurrency, SingleProducerConstrained = true, CancellationToken = cancellationToken });