C# Class Sharplike.Core.Scheduling.PrioritizedThreadPoolScheduler

The class for a prioritized scheduler. Internally the class uses SortedList for relatively efficient insertion and deletion of tasks, and is recommended only for multi-threaded schedulers.
Inheritance: IScheduler
ファイルを表示 Open project: eropple/sharplike

Protected Properties

Property Type Description
priorityList IScheduledTask>.SortedList

Public Methods

Method Description
AddTask ( IScheduledTask task ) : void

Adds a task to the priority queue. As no priority value has been given, the scheduler will use the delegate in TaskPriorityAlgorithm to determine a priority for the task. Failure to set TaskPriorityAlgorithm ahead of time will throw an exception.

AddTask ( Int32 priority, IScheduledTask task ) : void

Adds a task to the scheduler with the specified priority.

ClearTasks ( ) : void

Clears the scheduler of all tasks.

PrioritizedThreadPoolScheduler ( ) : System

Constructor.

Process ( ) : void

Dispatches a "go" message to all subscribed processes.

RemoveTask ( IScheduledTask task ) : System.Boolean

Remove a task from the scheduler. This is a fail-safe function; it will not throw an exception if the task is not in the scheduler. Note that this function only removes the first occasion of a task; if you have accidentally registered the same task multiple times, it only removes one.

ReorderTasks ( ) : void

Feeds all currently enqueued tasks through the designated TaskPriorityAlgorithm to reorder them. This is a computationally slow function and should be called with caution.

Private Methods

Method Description
RunTask ( Object data ) : void

Method Details

AddTask() public method

Adds a task to the priority queue. As no priority value has been given, the scheduler will use the delegate in TaskPriorityAlgorithm to determine a priority for the task. Failure to set TaskPriorityAlgorithm ahead of time will throw an exception.
public AddTask ( IScheduledTask task ) : void
task IScheduledTask The task to add to the scheduler.
return void

AddTask() public method

Adds a task to the scheduler with the specified priority.
public AddTask ( Int32 priority, IScheduledTask task ) : void
priority System.Int32 The current task's priority for scheduling.
task IScheduledTask The task to be queued.
return void

ClearTasks() public method

Clears the scheduler of all tasks.
public ClearTasks ( ) : void
return void

PrioritizedThreadPoolScheduler() public method

Constructor.
public PrioritizedThreadPoolScheduler ( ) : System
return System

Process() public method

Dispatches a "go" message to all subscribed processes.
public Process ( ) : void
return void

RemoveTask() public method

Remove a task from the scheduler. This is a fail-safe function; it will not throw an exception if the task is not in the scheduler. Note that this function only removes the first occasion of a task; if you have accidentally registered the same task multiple times, it only removes one.
public RemoveTask ( IScheduledTask task ) : System.Boolean
task IScheduledTask The task to remove.
return System.Boolean

ReorderTasks() public method

Feeds all currently enqueued tasks through the designated TaskPriorityAlgorithm to reorder them. This is a computationally slow function and should be called with caution.
public ReorderTasks ( ) : void
return void

Property Details

priorityList protected_oe property

protected SortedList priorityList
return IScheduledTask>.SortedList