/// <summary> /// Creates a dataflow builder from a batched join of multiple source blocks. /// </summary> /// <typeparam name="TOutput1"></typeparam> /// <typeparam name="TOutput2"></typeparam> /// <typeparam name="TOutput3"></typeparam> /// <param name="sourceBlock1"></param> /// <param name="sourceBlock2"></param> /// <param name="sourceBlock3"></param> /// <param name="batchSize"></param> /// <param name="joinOptions"></param> /// <returns></returns> public ISourceDataflowBuilder <Tuple <IList <TOutput1>, IList <TOutput2>, IList <TOutput3> > > BatchedJoin <TOutput1, TOutput2, TOutput3>(ISourceBlock <TOutput1> sourceBlock1, ISourceBlock <TOutput2> sourceBlock2, ISourceBlock <TOutput3> sourceBlock3, int batchSize, DataflowJoinOptions joinOptions = default(DataflowJoinOptions)) { if (sourceBlock1 == null) { throw new ArgumentNullException("sourceBlock1"); } if (sourceBlock2 == null) { throw new ArgumentNullException("sourceBlock2"); } if (sourceBlock3 == null) { throw new ArgumentNullException("sourceBlock3"); } var batchedJoinBlock = new BatchedJoinBlock <TOutput1, TOutput2, TOutput3>(batchSize, joinOptions.JoinBlockOptions); LinkHelper.Link(sourceBlock1, batchedJoinBlock.Target1, joinOptions.Target1LinkOptions); LinkHelper.Link(sourceBlock2, batchedJoinBlock.Target2, joinOptions.Target2LinkOptions); LinkHelper.Link(sourceBlock3, batchedJoinBlock.Target3, joinOptions.Target3LinkOptions); var multipleSourcesWrapper = new MultipleSourceDataflowWrapper(new IDataflowBlock[] { sourceBlock1, sourceBlock2, sourceBlock3 }); var sourceWrapper = new ReceivableSourceDataflowWrapper <Tuple <IList <TOutput1>, IList <TOutput2>, IList <TOutput3> > >(multipleSourcesWrapper, batchedJoinBlock, batchedJoinBlock); return(FromSource(sourceWrapper)); }
public ISourceDataflowBuilder <TOutput[]> Batch(int batchSize, DataflowBatchOptions batchOptions = default(DataflowBatchOptions)) { var batchBlock = new BatchBlock <TOutput>(batchSize, batchOptions.BatchBlockOptions); var propagateCompletion = Link(batchBlock, batchOptions.LinkOptions, null); var sourceWrapper = new MultipleSourceDataflowWrapper(_sourceBlocks); return(new SourceDataflowBuilder <TOutput[]>(sourceWrapper, sourceWrapper, batchBlock, propagateCompletion)); }
public IDataflowBuilder LinkToTarget(ITargetBlock <TOutput> targetBlock, DataflowLinkOptions linkOptions, Predicate <TOutput> predicate) { if (targetBlock == null) { throw new ArgumentNullException("targetBlock"); } var propagateCompletion = Link(targetBlock, linkOptions, predicate); var sourceWrapper = new MultipleSourceDataflowWrapper(_sourceBlocks); return(new DataflowBuilder(sourceWrapper, sourceWrapper, targetBlock, propagateCompletion)); }
public ISourceDataflowBuilder <TOutput2> LinkToPropagator <TOutput2>(IPropagatorBlock <TOutput, TOutput2> propagatorBlock, DataflowLinkOptions linkOptions, Predicate <TOutput> predicate) { if (propagatorBlock == null) { throw new ArgumentNullException("propagatorBlock"); } var propagateCompletion = Link(propagatorBlock, linkOptions, predicate); var sourceWrapper = new MultipleSourceDataflowWrapper(_sourceBlocks); return(new SourceDataflowBuilder <TOutput2>(sourceWrapper, sourceWrapper, propagatorBlock, propagateCompletion)); }
public ISourceDataflowBuilder <TOutput> WriteOnce(Func <TOutput, TOutput> cloningFunction, DataflowWriteOnceOptions writeOnceOptions = default(DataflowWriteOnceOptions)) { if (cloningFunction == null) { throw new ArgumentNullException("cloningFunction"); } var writeOnceBlock = new WriteOnceBlock <TOutput>(cloningFunction, writeOnceOptions.WriteOnceBlockOptions); var propagateCompletion = Link(writeOnceBlock, writeOnceOptions.LinkOptions, null); var sourceWrapper = new MultipleSourceDataflowWrapper(_sourceBlocks); return(new SourceDataflowBuilder <TOutput>(sourceWrapper, sourceWrapper, writeOnceBlock, propagateCompletion)); }
/// <summary> /// Creates a dataflow builder from a join of multiple source blocks. /// </summary> /// <typeparam name="TOutput1"></typeparam> /// <typeparam name="TOutput2"></typeparam> /// <param name="sourceBlock1"></param> /// <param name="sourceBlock2"></param> /// <param name="joinOptions"></param> /// <returns></returns> public ISourceDataflowBuilder <Tuple <TOutput1, TOutput2> > Join <TOutput1, TOutput2>(ISourceBlock <TOutput1> sourceBlock1, ISourceBlock <TOutput2> sourceBlock2, DataflowJoinOptions joinOptions = default(DataflowJoinOptions)) { if (sourceBlock1 == null) { throw new ArgumentNullException("sourceBlock1"); } if (sourceBlock2 == null) { throw new ArgumentNullException("sourceBlock2"); } var joinBlock = new JoinBlock <TOutput1, TOutput2>(joinOptions.JoinBlockOptions); LinkHelper.Link(sourceBlock1, joinBlock.Target1, joinOptions.Target1LinkOptions); LinkHelper.Link(sourceBlock2, joinBlock.Target2, joinOptions.Target2LinkOptions); var multipleSourcesWrapper = new MultipleSourceDataflowWrapper(new IDataflowBlock[] { sourceBlock1, sourceBlock2 }); var sourceWrapper = new ReceivableSourceDataflowWrapper <Tuple <TOutput1, TOutput2> >(multipleSourcesWrapper, joinBlock, joinBlock); return(FromSource(sourceWrapper)); }