< Summary

Information
Class: CounterpointCollective.Dataflow.BoundedPropagatorBlockExtensions
Assembly: Dataflow.Composable
File(s): /builds/counterpointcollective/composabledataflowblocks/Source/Dataflow.Composable/DataFlow/BoundedPropagatorBlockExtensions.cs
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 39
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
WithBoundedCapacity(...)100%11100%

File(s)

/builds/counterpointcollective/composabledataflowblocks/Source/Dataflow.Composable/DataFlow/BoundedPropagatorBlockExtensions.cs

#LineLine coverage
 1using System.Threading.Tasks.Dataflow;
 2
 3namespace CounterpointCollective.Dataflow
 4{
 5    public static class BoundedPropagatorBlockExtensions
 6    {
 7        /// <summary>
 8        /// Wraps an <see cref="IPropagatorBlock{I,O}"/> block into a <see cref="BoundedPropagatorBlock{I,O}"/>
 9        /// with the specified <paramref name="boundedCapacity"/>.
 10        /// </summary>
 11        /// <typeparam name="I">The type of input messages accepted by the propagator block.</typeparam>
 12        /// <typeparam name="O">The type of output messages produced by the propagator block.</typeparam>
 13        /// <param name="b">The source propagator block to wrap with bounded capacity.</param>
 14        /// <param name="boundedCapacity">The maximum number of messages that can be buffered by the block.</param>
 15        /// <returns>A <see cref="BoundedPropagatorBlock{I,O}"/> that wraps the specified block <paramref name="b"/> and
 16        /// limit <paramref name="boundedCapacity"/>.</returns>
 17        /// <example>
 18        /// <code>
 19        ///
 20        /// // Create a custom block
 21        /// var myBlock = DataflowBlock.Encapsulate(
 22        ///     new TransformBlock&lt;int, int&gt;(a => a + 1),
 23        ///     new TransformBlock&lt;int, int&gt;(a => a - 1)
 24        /// );
 25        ///
 26        /// // Wrap your custom block with bounded capacity
 27        /// var boundedBlock = myBlock.WithBoundedCapacity(3);
 28        ///
 29        /// //You can count how many messages are currently owned by the block
 30        /// var c = boundedBlock.Count;
 31        ///
 32        /// //You can also dynamically change the capacity
 33        /// boundedBlock.SetBoundedCapacity(10);
 34        /// </code>
 35        /// </example>
 36        public static BoundedPropagatorBlock<I, O> WithBoundedCapacity<I, O>(this IPropagatorBlock<I, O> b, int boundedC
 237        => new (b, boundedCapacity);
 38    }
 39}