AcUtils
A high performance abstraction layer for AccuRev
Public Member Functions | Protected Member Functions | Properties | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler Class Reference

Provides a task scheduler that ensures a maximum concurrency level while running on top of the ThreadPool. More...

Collaboration diagram for System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler:
Collaboration graph
[legend]

Public Member Functions

 LimitedConcurrencyLevelTaskScheduler (int maxDegreeOfParallelism)
 Initializes an instance of the LimitedConcurrencyLevelTaskScheduler class with the specified degree of parallelism. More...
 

Protected Member Functions

sealed override void QueueTask (Task task)
 Queues a task to the scheduler. More...
 
sealed override bool TryExecuteTaskInline (Task task, bool taskWasPreviouslyQueued)
 Attempts to execute the specified task on the current thread. More...
 
sealed override bool TryDequeue (Task task)
 Attempts to remove a previously scheduled task from the scheduler. More...
 
sealed override IEnumerable< Task > GetScheduledTasks ()
 Gets an enumerable of the tasks currently scheduled on this scheduler. More...
 

Properties

sealed override int MaximumConcurrencyLevel [get]
 Gets the maximum concurrency level supported by this scheduler. More...
 

Private Member Functions

void NotifyThreadPoolOfPendingWork ()
 Informs the ThreadPool that there's work to be executed for this scheduler. More...
 

Private Attributes

readonly LinkedList< Task > _tasks = new LinkedList<Task>()
 The list of tasks to be executed. More...
 
readonly int _maxDegreeOfParallelism
 The maximum concurrency level allowed by this scheduler. More...
 
int _delegatesQueuedOrRunning = 0
 Whether the scheduler is currently processing work items. More...
 

Static Private Attributes

static bool _currentThreadIsProcessingItems
 Whether the current thread is processing work items. More...
 

Detailed Description

Provides a task scheduler that ensures a maximum concurrency level while running on top of the ThreadPool.

Definition at line 22 of file LimitedConcurrencyLevelTaskScheduler.cs.

Constructor & Destructor Documentation

System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler.LimitedConcurrencyLevelTaskScheduler ( int  maxDegreeOfParallelism)
inline

Initializes an instance of the LimitedConcurrencyLevelTaskScheduler class with the specified degree of parallelism.

Parameters
maxDegreeOfParallelismThe maximum degree of parallelism provided by this scheduler.

Definition at line 39 of file LimitedConcurrencyLevelTaskScheduler.cs.

Member Function Documentation

sealed override IEnumerable<Task> System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler.GetScheduledTasks ( )
inlineprotected

Gets an enumerable of the tasks currently scheduled on this scheduler.

Returns
An enumerable of the tasks currently scheduled.

Definition at line 131 of file LimitedConcurrencyLevelTaskScheduler.cs.

void System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler.NotifyThreadPoolOfPendingWork ( )
inlineprivate

Informs the ThreadPool that there's work to be executed for this scheduler.

Definition at line 65 of file LimitedConcurrencyLevelTaskScheduler.cs.

sealed override void System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler.QueueTask ( Task  task)
inlineprotected

Queues a task to the scheduler.

Parameters
taskThe task to be queued.

Definition at line 47 of file LimitedConcurrencyLevelTaskScheduler.cs.

sealed override bool System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler.TryDequeue ( Task  task)
inlineprotected

Attempts to remove a previously scheduled task from the scheduler.

Parameters
taskThe task to be removed.
Returns
Whether the task could be found and removed.

Definition at line 121 of file LimitedConcurrencyLevelTaskScheduler.cs.

sealed override bool System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler.TryExecuteTaskInline ( Task  task,
bool  taskWasPreviouslyQueued 
)
inlineprotected

Attempts to execute the specified task on the current thread.

Parameters
taskThe task to be executed.
taskWasPreviouslyQueued
Returns
Whether the task could be executed on the current thread.

Definition at line 106 of file LimitedConcurrencyLevelTaskScheduler.cs.

Member Data Documentation

bool System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler._currentThreadIsProcessingItems
staticprivate

Whether the current thread is processing work items.

Definition at line 26 of file LimitedConcurrencyLevelTaskScheduler.cs.

int System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler._delegatesQueuedOrRunning = 0
private

Whether the scheduler is currently processing work items.

Definition at line 32 of file LimitedConcurrencyLevelTaskScheduler.cs.

readonly int System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler._maxDegreeOfParallelism
private

The maximum concurrency level allowed by this scheduler.

Definition at line 30 of file LimitedConcurrencyLevelTaskScheduler.cs.

readonly LinkedList<Task> System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler._tasks = new LinkedList<Task>()
private

The list of tasks to be executed.

Definition at line 28 of file LimitedConcurrencyLevelTaskScheduler.cs.

Property Documentation

sealed override int System.Threading.Tasks.Schedulers.LimitedConcurrencyLevelTaskScheduler.MaximumConcurrencyLevel
get

Gets the maximum concurrency level supported by this scheduler.

Definition at line 127 of file LimitedConcurrencyLevelTaskScheduler.cs.