| | | 1 | | using CounterpointCollective.Dataflow.Encapsulation; |
| | | 2 | | using System.Threading.Tasks.Dataflow; |
| | | 3 | | |
| | | 4 | | namespace CounterpointCollective.Dataflow |
| | | 5 | | { |
| | | 6 | | public class ChoiceBlock<TInput, TOutput> |
| | | 7 | | : AbstractEncapsulatedPropagatorBlock<TInput, TOutput> |
| | | 8 | | , IResizablePropagatorBlock<TInput, TOutput> |
| | | 9 | | { |
| | | 10 | | private readonly IResizablePropagatorBlock<TInput, TOutput> _innerBlock; |
| | | 11 | | |
| | 1 | 12 | | public ChoiceBlock( |
| | 1 | 13 | | Predicate<TInput> predicate, |
| | 1 | 14 | | IPropagatorBlock<TInput, TOutput> thenBlock, |
| | 1 | 15 | | IPropagatorBlock<TInput, TOutput> elseBlock, |
| | 1 | 16 | | ExecutionDataflowBlockOptions options |
| | 2 | 17 | | ) => _innerBlock = |
| | 1 | 18 | | options.EnsureOrdered |
| | 1 | 19 | | ? new OrderPreservingChoiceBlock<TInput, TOutput>(predicate, thenBlock, elseBlock, options) |
| | 1 | 20 | | : new NonOrderPreservingChoiceBlock<TInput, TOutput>(predicate, thenBlock, elseBlock, options); |
| | | 21 | | |
| | | 22 | | public int BoundedCapacity |
| | | 23 | | { |
| | 0 | 24 | | get => _innerBlock.BoundedCapacity; |
| | 0 | 25 | | set => _innerBlock.BoundedCapacity = value; |
| | | 26 | | } |
| | | 27 | | |
| | 0 | 28 | | public int Count => _innerBlock.Count; |
| | | 29 | | |
| | | 30 | | /// <exclude/> |
| | 100001 | 31 | | protected override ITargetBlock<TInput> TargetSide => _innerBlock; |
| | | 32 | | |
| | | 33 | | /// <exclude/> |
| | 100004 | 34 | | protected override ISourceBlock<TOutput> SourceSide => _innerBlock; |
| | | 35 | | } |
| | | 36 | | } |