Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ BatchBlock() [2/2]

System.Threading.Tasks.Dataflow.BatchBlock< T >.BatchBlock ( int batchSize,
GroupingDataflowBlockOptions dataflowBlockOptions )
inline

Definition at line 777 of file BatchBlock.cs.

778 {
779 if (batchSize < 1)
780 {
781 throw new ArgumentOutOfRangeException("batchSize", System.SR.ArgumentOutOfRange_GenericPositive);
782 }
783 if (dataflowBlockOptions == null)
784 {
785 throw new ArgumentNullException("dataflowBlockOptions");
786 }
787 if (dataflowBlockOptions.BoundedCapacity > 0 && dataflowBlockOptions.BoundedCapacity < batchSize)
788 {
789 throw new ArgumentOutOfRangeException("batchSize", System.SR.ArgumentOutOfRange_BatchSizeMustBeNoGreaterThanBoundedCapacity);
790 }
794 if (dataflowBlockOptions.BoundedCapacity > 0)
795 {
796 itemsRemovedAction = delegate(ISourceBlock<T[]> owningSource, int count)
797 {
798 ((BatchBlock<T>)owningSource)._target.OnItemsRemoved(count);
799 };
801 }
803 {
806 _target = new BatchBlockTargetCore(this, batchSize, delegate(T[] batch)
807 {
811 {
813 }, CancellationToken.None, Common.GetContinuationOptions(), TaskScheduler.Default);
815 {
816 IDataflowBlock dataflowBlock = (BatchBlock<T>)state;
817 dataflowBlock.Fault(completed.Exception);
818 }, this, CancellationToken.None, Common.GetContinuationOptions() | TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.Default);
820 {
821 ((BatchBlockTargetCore)state).Complete(null, dropPendingMessages: true, releaseReservedMessages: false);
822 }, _target);
824 if (log.IsEnabled())
825 {
826 log.DataflowBlockCreated(this, dataflowBlockOptions);
827 }
828 }
static string ArgumentOutOfRange_GenericPositive
Definition SR.cs:1018
static string ArgumentOutOfRange_BatchSizeMustBeNoGreaterThanBoundedCapacity
Definition SR.cs:14
Definition SR.cs:7
readonly BatchBlockTargetCore _target
static TaskContinuationOptions GetContinuationOptions(TaskContinuationOptions toInclude=TaskContinuationOptions.None)
Definition Common.cs:262
static void WireCancellationToComplete(CancellationToken cancellationToken, Task completionTask, Action< object > completeAction, object completeState)
Definition Common.cs:93
Task ContinueWith(Action< Task< TResult > > continuationAction)
Definition Task.cs:263

References System.Threading.Tasks.Dataflow.BatchBlock< T >._source, System.Threading.Tasks.Dataflow.BatchBlock< T >._target, System.Threading.Tasks.Dataflow.Internal.SourceCore< TOutput >.AddMessage(), System.SR.ArgumentOutOfRange_BatchSizeMustBeNoGreaterThanBoundedCapacity, System.SR.ArgumentOutOfRange_GenericPositive, System.Threading.Tasks.Dataflow.Internal.SourceCore< TOutput >.Complete(), System.Threading.Tasks.Dataflow.Internal.SourceCore< TOutput >.Completion, System.Threading.Tasks.Dataflow.BatchBlock< T >.BatchBlockTargetCore.Completion, System.Threading.Tasks.Task< TResult >.ContinueWith(), System.count, System.Threading.Tasks.Dataflow.BatchBlock< T >.BatchBlockTargetCore.CountItems(), System.Threading.Tasks.TaskScheduler.Default, System.Threading.Tasks.Dataflow.Internal.Common.GetContinuationOptions(), System.Threading.Tasks.Dataflow.Internal.DataflowEtwProvider.Log, System.Threading.CancellationToken.None, System.state, and System.Threading.Tasks.Dataflow.Internal.Common.WireCancellationToComplete().