public JoinBlock(GroupingDataflowBlockOptions dataflowBlockOptions) { if (dataflowBlockOptions == null) { throw new ArgumentNullException("dataflowBlockOptions"); } this.dataflowBlockOptions = dataflowBlockOptions; this.compHelper = new CompletionHelper(dataflowBlockOptions); target1 = new JoinTarget <T1> (this, SignalArrivalTarget, compHelper, () => outgoing.IsCompleted, dataflowBlockOptions, dataflowBlockOptions.Greedy, TryAdd1); target2 = new JoinTarget <T2> (this, SignalArrivalTarget, compHelper, () => outgoing.IsCompleted, dataflowBlockOptions, dataflowBlockOptions.Greedy, TryAdd2); target3 = new JoinTarget <T3> (this, SignalArrivalTarget, compHelper, () => outgoing.IsCompleted, dataflowBlockOptions, dataflowBlockOptions.Greedy, TryAdd3); outgoing = new OutgoingQueue <Tuple <T1, T2, T3> > ( this, compHelper, () => target1.Buffer.IsCompleted || target2.Buffer.IsCompleted || target3.Buffer.IsCompleted, _ => { target1.DecreaseCount(); target2.DecreaseCount(); target3.DecreaseCount(); }, dataflowBlockOptions); }
public static CompletionHelper GetNew() { CompletionHelper temp = new CompletionHelper(); temp.source = new TaskCompletionSource <object> (); return(temp); }
public BroadcastOutgoingQueue( ISourceBlock <T> block, CompletionHelper compHelper, Func <bool> externalCompleteTester, Action <int> decreaseItemsCount, DataflowBlockOptions options, bool hasCloner) : base(compHelper, externalCompleteTester, decreaseItemsCount, options) { targets = new BroadcastTargetCollection <T> (block, hasCloner); }
public PassingMessageBox(BlockingCollection <TInput> messageQueue, CompletionHelper compHelper, Func <bool> externalCompleteTester, Action processQueue, DataflowBlockOptions dataflowBlockOptions) : base(messageQueue, compHelper, externalCompleteTester) { this.dataflowBlockOptions = dataflowBlockOptions; this.processQueue = processQueue; }
TransformBlock(ExecutionDataflowBlockOptions dataflowBlockOptions) { if (dataflowBlockOptions == null) { throw new ArgumentNullException("dataflowBlockOptions"); } this.dataflowBlockOptions = dataflowBlockOptions; this.compHelper = new CompletionHelper(dataflowBlockOptions); }
public PassingMessageBox( ITargetBlock <TInput> target, BlockingCollection <TInput> messageQueue, CompletionHelper compHelper, Func <bool> externalCompleteTester, Action <bool> processQueue, DataflowBlockOptions dataflowBlockOptions, bool greedy = true, Func <bool> canAccept = null) : base(target, messageQueue, compHelper, externalCompleteTester, dataflowBlockOptions, greedy, canAccept) { this.processQueue = processQueue; }
public OutgoingQueue( ISourceBlock <T> block, CompletionHelper compHelper, Func <bool> externalCompleteTester, Action <int> decreaseItemsCount, DataflowBlockOptions options, Func <T, int> countSelector = null) : base(compHelper, externalCompleteTester, decreaseItemsCount, options) { targets = new TargetCollection <T> (block); this.countSelector = countSelector; }
protected ExecutingMessageBoxBase( ITargetBlock <TInput> target, BlockingCollection <TInput> messageQueue, CompletionHelper compHelper, Func <bool> externalCompleteTester, Action outgoingQueueComplete, ExecutionDataflowBlockOptions options) : base( target, messageQueue, compHelper, externalCompleteTester, options) { this.Options = options; this.outgoingQueueComplete = outgoingQueueComplete; }
public ExecutingMessageBox( ITargetBlock <TInput> target, BlockingCollection <TInput> messageQueue, CompletionHelper compHelper, Func <bool> externalCompleteTester, Func <bool> processItem, Action outgoingQueueComplete, ExecutionDataflowBlockOptions options) : base( target, messageQueue, compHelper, externalCompleteTester, outgoingQueueComplete, options) { this.processItem = processItem; }
public JoinTarget( IDataflowBlock joinBlock, Action signal, CompletionHelper helper, Func <bool> externalCompleteTester, DataflowBlockOptions options, bool greedy, Func <bool> canAccept) : base(null, new BlockingCollection <TTarget> (), helper, externalCompleteTester, options, greedy, canAccept) { this.joinBlock = joinBlock; this.signal = signal; Target = this; }
protected OutgoingQueueBase( CompletionHelper compHelper, Func <bool> externalCompleteTester, Action <int> decreaseItemsCount, DataflowBlockOptions options) { IsProcessing = new AtomicBoolean(); Store = new ConcurrentQueue <T> (); Outgoing = new BlockingCollection <T> (Store); this.compHelper = compHelper; this.externalCompleteTester = externalCompleteTester; this.options = options; this.decreaseItemsCount = decreaseItemsCount; }
protected MessageBox( ITargetBlock <TInput> target, BlockingCollection <TInput> messageQueue, CompletionHelper compHelper, Func <bool> externalCompleteTester, DataflowBlockOptions options, bool greedy = true, Func <bool> canAccept = null) { this.Target = target; this.CompHelper = compHelper; this.MessageQueue = messageQueue; this.externalCompleteTester = externalCompleteTester; this.options = options; this.greedy = greedy; this.canAccept = canAccept; }
public BatchedJoinBlock(int batchSize, GroupingDataflowBlockOptions dataflowBlockOptions) { if (batchSize <= 0) { throw new ArgumentOutOfRangeException( "batchSize", batchSize, "The batchSize must be positive."); } if (dataflowBlockOptions == null) { throw new ArgumentNullException("dataflowBlockOptions"); } if (!dataflowBlockOptions.Greedy) { throw new ArgumentException( "Greedy must be true for this dataflow block.", "dataflowBlockOptions"); } if (dataflowBlockOptions.BoundedCapacity != DataflowBlockOptions.Unbounded) { throw new ArgumentException( "BoundedCapacity must be Unbounded or -1 for this dataflow block.", "dataflowBlockOptions"); } BatchSize = batchSize; options = dataflowBlockOptions; completionHelper = CompletionHelper.GetNew(options); target1 = new JoinTarget <T1> ( this, SignalTarget, completionHelper, () => outgoing.IsCompleted, dataflowBlockOptions, true, TryAdd); target2 = new JoinTarget <T2> ( this, SignalTarget, completionHelper, () => outgoing.IsCompleted, dataflowBlockOptions, true, TryAdd); target3 = new JoinTarget <T3> ( this, SignalTarget, completionHelper, () => outgoing.IsCompleted, dataflowBlockOptions, true, TryAdd); outgoing = new OutgoingQueue <Tuple <IList <T1>, IList <T2>, IList <T3> > > ( this, completionHelper, () => target1.Buffer.IsCompleted || target2.Buffer.IsCompleted || target3.Buffer.IsCompleted, _ => { target1.DecreaseCount(); target2.DecreaseCount(); target3.DecreaseCount(); }, options); }
public BufferBlock(DataflowBlockOptions dataflowBlockOptions) { if (dataflowBlockOptions == null) { throw new ArgumentNullException("dataflowBlockOptions"); } this.dataflowBlockOptions = dataflowBlockOptions; this.compHelper = new CompletionHelper(dataflowBlockOptions); this.messageBox = new PassingMessageBox <T> (this, messageQueue, compHelper, () => outgoing.IsCompleted, _ => ProcessQueue(), dataflowBlockOptions); this.outgoing = new OutgoingQueue <T> (this, compHelper, () => messageQueue.IsCompleted, messageBox.DecreaseCount, dataflowBlockOptions); }
public BroadcastBlock(Func <T, T> cloningFunction, DataflowBlockOptions dataflowBlockOptions) { if (dataflowBlockOptions == null) { throw new ArgumentNullException("dataflowBlockOptions"); } this.cloningFunction = cloningFunction; this.dataflowBlockOptions = dataflowBlockOptions; this.compHelper = new CompletionHelper(dataflowBlockOptions); this.messageBox = new PassingMessageBox <T> (this, messageQueue, compHelper, () => outgoing.IsCompleted, _ => BroadcastProcess(), dataflowBlockOptions); this.outgoing = new BroadcastOutgoingQueue <T> (this, compHelper, () => messageQueue.IsCompleted, messageBox.DecreaseCount, dataflowBlockOptions, cloningFunction != null); }
public WriteOnceBlock(Func <T, T> cloningFunction, DataflowBlockOptions dataflowBlockOptions) { if (dataflowBlockOptions == null) { throw new ArgumentNullException("dataflowBlockOptions"); } this.cloningFunction = cloningFunction; this.dataflowBlockOptions = dataflowBlockOptions; this.compHelper = CompletionHelper.GetNew(dataflowBlockOptions); this.messageBox = new PassingMessageBox <T> (this, messageQueue, compHelper, () => true, _ => BroadcastProcess(), dataflowBlockOptions, canAccept: () => written.TrySet()); this.outgoing = new BroadcastOutgoingQueue <T> (this, compHelper, () => messageQueue.IsCompleted, messageBox.DecreaseCount, dataflowBlockOptions, cloningFunction != null); }
public BatchBlock(int batchSize, GroupingDataflowBlockOptions dataflowBlockOptions) { if (batchSize <= 0) { throw new ArgumentOutOfRangeException("batchSize", batchSize, "The batchSize must be positive."); } if (dataflowBlockOptions == null) { throw new ArgumentNullException("dataflowBlockOptions"); } if (dataflowBlockOptions.BoundedCapacity != -1 && batchSize > dataflowBlockOptions.BoundedCapacity) { throw new ArgumentOutOfRangeException("batchSize", "The batchSize must be smaller than the value of BoundedCapacity."); } this.batchSize = batchSize; this.dataflowBlockOptions = dataflowBlockOptions; this.compHelper = CompletionHelper.GetNew(dataflowBlockOptions); Action <bool> processQueue; Func <bool> canAccept; if (dataflowBlockOptions.MaxNumberOfGroups == -1) { processQueue = newItem => BatchProcess(newItem ? 1 : 0); canAccept = null; } else { processQueue = _ => BatchProcess(); canAccept = TryAdd; } this.messageBox = new PassingMessageBox <T> (this, messageQueue, compHelper, () => outgoing.IsCompleted, processQueue, dataflowBlockOptions, dataflowBlockOptions.Greedy, canAccept); this.outgoing = new OutgoingQueue <T[]> (this, compHelper, () => messageQueue.IsCompleted, messageBox.DecreaseCount, dataflowBlockOptions, batch => batch.Length); }
public MessageOutgoingQueue(CompletionHelper compHelper, Func <bool> externalCompleteTester) { this.outgoing = new BlockingCollection <T> (store); this.compHelper = compHelper; this.externalCompleteTester = externalCompleteTester; }
public void Setup () { helper = CompletionHelper.GetNew (); }
public JoinTarget(JoinBlock <T1, T2> joinBlock, Action signal, BlockingCollection <TTarget> buffer, CompletionHelper helper) : base(buffer, helper, () => joinBlock.outgoing.IsCompleted) { this.joinBlock = joinBlock; this.buffer = buffer; this.signal = signal; }
public MessageBox(BlockingCollection <TInput> messageQueue, CompletionHelper compHelper, Func <bool> externalCompleteTester) { this.compHelper = compHelper; this.messageQueue = messageQueue; this.externalCompleteTester = externalCompleteTester; }
public static CompletionHelper GetNew () { CompletionHelper temp = new CompletionHelper (); temp.source = new TaskCompletionSource<object> (); return temp; }