在ConcurrentExclusiveSchedulerPair中maxItemsPerTask有什么影响?

时间:2015-03-24 23:14:37

标签: .net task-parallel-library

MSDN将ConcurrentExclusiveSchedulerPair maxItemsPerTask定义为

  

maxItemsPerTask
  类型:System.Int32
  为该对使用的每个基础计划任务处理的最大任务数。

     

https://msdn.microsoft.com/en-us/library/hh194750(v=vs.110).aspx

但我不明白这个定义。

如果我设置了这个(例如5)会发生什么?

1 个答案:

答案 0 :(得分:4)

ConcurrentExclusiveSchedulerPair将允许creation of up to maxConcurrencyLevel concurrent tasks(或单个独占的)处理最多maxItemsPerTask个任务然后完成,或者作为参考来源解释它:

/// <summary>The maximum number of tasks we can process before recycling our runner tasks.</summary>
private readonly int m_maxItemsPerTask;

处理并发任务can be stopped before reaching maxItemsPerTask if there's an exclusive task waiting to be processed的任务,但不是相反,maxItemsPerTask可以用来限制独占任务以防止并发任务的饥饿。