Table of Contents

Class BoundedPropagatorBlockExtensions

Namespace
CounterpointCollective.Dataflow
Assembly
Dataflow.Composable.dll
public static class BoundedPropagatorBlockExtensions
Inheritance
BoundedPropagatorBlockExtensions
Inherited Members

Methods

WithBoundedCapacity<I, O>(IPropagatorBlock<I, O>, int)

Wraps an IPropagatorBlock<TInput, TOutput> block into a BoundedPropagatorBlock<I, O> with the specified boundedCapacity.

public static BoundedPropagatorBlock<I, O> WithBoundedCapacity<I, O>(this IPropagatorBlock<I, O> b, int boundedCapacity)

Parameters

b IPropagatorBlock<I, O>

The source propagator block to wrap with bounded capacity.

boundedCapacity int

The maximum number of messages that can be buffered by the block.

Returns

BoundedPropagatorBlock<I, O>

A BoundedPropagatorBlock<I, O> that wraps the specified block b and enforces the given capacity limit boundedCapacity.

Type Parameters

I

The type of input messages accepted by the propagator block.

O

The type of output messages produced by the propagator block.

Examples

// Create a custom block
var myBlock = DataflowBlock.Encapsulate(
    new TransformBlock<int, int>(a => a + 1),
    new TransformBlock<int, int>(a => a - 1)
);

// Wrap your custom block with bounded capacity
var boundedBlock = myBlock.WithBoundedCapacity(3);

//You can count how many messages are currently owned by the block
var c = boundedBlock.Count;

//You can also dynamically change the capacity
boundedBlock.SetBoundedCapacity(10);