Table of Contents

Class ParallelBlock<I, T, O>

Namespace
CounterpointCollective.Dataflow
Assembly
Dataflow.Composable.dll

To prevent deadlocks, Source will always accept messages. However, the block itself will only accept new messages if the combined count of Source and the joining side (using either the smallest or largest queue count, depending on the configured mode) is below the capacity limit.

Be careful when you pass GuaranteedBroadcastBlockBoundedCapacityMode.LargestQueue in the options. This may trigger a deadlock in some cases, namely:

  • Queue[1] is empty.
  • Queue[2] has items
  • The ParBlock is full; it will not enqueue more messages before some are consumed.
  • worker 1 requires to consume messages before it will produce a next message, e.g. because it is batching.
  • worker 2 cannot consume more messages at the moment because it's output side is full The JoiningTarget will not consume messages until all workers have output available, causing a deadlock.
public class ParallelBlock<I, T, O> : AbstractEncapsulatedPropagatorBlock<I, O>, IReceivableSourceBlock<O>, IPropagatorBlock<I, O>, ISourceBlock<O>, ITargetBlock<I>, IDataflowBlock

Type Parameters

I
T
O
Inheritance
AbstractEncapsulatedSourceBlock<O>
AbstractEncapsulatedPropagatorBlock<I, O>
ParallelBlock<I, T, O>
Implements
Inherited Members
Extension Methods

Constructors

ParallelBlock(int, Func<T[], O>, GuaranteedBroadcastBlockOptions)

public ParallelBlock(int degreeOfParallelism, Func<T[], O> recombine, GuaranteedBroadcastBlockOptions options)

Parameters

degreeOfParallelism int
recombine Func<T[], O>
options GuaranteedBroadcastBlockOptions

Properties

Count

Items currently in the block, being either in the input side or output side. When they leave for the workers, they are no longer counted here. When they return from the workers, they are counted here again. This can cause the Count to be temporarily higher than the BoundedCapacity, just like in the TransformManyBlock.

public int Count { get; }

Property Value

int

InputCount

public int InputCount { get; }

Property Value

int

OutputCount

public int OutputCount { get; }

Property Value

int

Methods

Hookup(IPropagatorBlock<I, T>, DataflowLinkOptions)

public void Hookup(IPropagatorBlock<I, T> worker, DataflowLinkOptions options)

Parameters

worker IPropagatorBlock<I, T>
options DataflowLinkOptions

LinkWorkers(IPropagatorBlock<I, T>[], DataflowLinkOptions)

Convenience method to link all the workers in one go.

public void LinkWorkers(IPropagatorBlock<I, T>[] workers, DataflowLinkOptions options)

Parameters

workers IPropagatorBlock<I, T>[]
options DataflowLinkOptions