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
bIPropagatorBlock<I, O>The source propagator block to wrap with bounded capacity.
boundedCapacityintThe maximum number of messages that can be buffered by the block.
Returns
- BoundedPropagatorBlock<I, O>
A BoundedPropagatorBlock<I, O> that wraps the specified block
band enforces the given capacity limitboundedCapacity.
Type Parameters
IThe type of input messages accepted by the propagator block.
OThe 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);