C# Класс DotNetWorkQueue.TaskScheduling.SmartThreadPoolTaskScheduler

A task scheduler for IConsumerQueueScheduler This uses SmartThreadPool https://github.com/amibar/SmartThreadPool to handle the threads internally
Наследование: ATaskScheduler
Показать файл Открыть проект

Private Properties

Свойство Тип Описание
PostExecuteWorkItemCallback void

Открытые методы

Метод Описание
AddTask ( Task task ) : void

Adds a new task to the scheduler.

AddWorkGroup ( string name, int concurrencyLevel ) : IWorkGroup

Adds a new work group.

AddWorkGroup ( string name, int concurrencyLevel, int maxQueueSize ) : IWorkGroup

Adds a new work group.

RoomForNewWorkGroupTask ( IWorkGroup group ) : RoomForNewTaskResult

If true, the task scheduler has room for the specified work group task

SmartThreadPoolTaskScheduler ( ITaskSchedulerConfiguration configuration, IWaitForEventOrCancelThreadPool waitForFreeThread, IMetrics metrics ) : System

Initializes a new instance of the SmartThreadPoolTaskScheduler class.

Start ( ) : void

Starts this instance.

Subscribe ( ) : int

Informs the scheduler that it has another client connected

UnSubscribe ( int id ) : void

Informs the scheduler that a client has disconnected

Защищенные методы

Метод Описание
DeincrementCounter ( ) : void

De-increments the counter for the running tasks

DeincrementGroup ( IWorkGroup group ) : void

De-increments the task counter for a specific group.

Dispose ( bool disposing ) : void

Releases unmanaged and - optionally - managed resources.

GetScheduledTasks ( ) : IEnumerable

Gets the tasks currently scheduled to this scheduler.

This will always return an empty enumerable, as tasks are launched as soon as they're queued; we also don't want the .net scheduler to mess with our internal queue.

HaveRoomForWorkGroupTask ( IWorkGroup group ) : bool

Returns true if the work group has room for a new task

IncrementCounter ( ) : void

Increments the counter for the running tasks

IncrementGroup ( IWorkGroup group ) : void

Increments the task count for a specific group

QueueTask ( Task task ) : void

Queues a T:System.Threading.Tasks.Task to the scheduler.

SetWaitHandle ( IWorkGroup group ) : void

Sets the wait handle.

ThrowIfDisposed ( [ name = "" ) : void

Throws an exception if this instance has been disposed.

TryExecuteTaskInline ( Task task, bool taskWasPreviouslyQueued ) : bool

Runs the provided task on the current thread.

TryExecuteTaskWrapped ( Task task, StateInformation state ) : StateInformation

A wrapper for executing the task, so that we can return the state information back to the caller

Приватные методы

Метод Описание
PostExecuteWorkItemCallback ( IWorkItemResult wir ) : void

Fires after each task is complete.

Описание методов

AddTask() публичный Метод

Adds a new task to the scheduler.
public AddTask ( Task task ) : void
task Task The task.
Результат void

AddWorkGroup() публичный Метод

Adds a new work group.
public AddWorkGroup ( string name, int concurrencyLevel ) : IWorkGroup
name string The name.
concurrencyLevel int The concurrency level.
Результат IWorkGroup

AddWorkGroup() публичный Метод

Adds a new work group.
Start must be called on the scheduler before adding work groups
public AddWorkGroup ( string name, int concurrencyLevel, int maxQueueSize ) : IWorkGroup
name string The name.
concurrencyLevel int The concurrency level.
maxQueueSize int Maximum size of the queue. Work groups have a queue that is separate per queue, and is not shared with non work group items
Результат IWorkGroup

DeincrementCounter() защищенный Метод

De-increments the counter for the running tasks
protected DeincrementCounter ( ) : void
Результат void

DeincrementGroup() защищенный Метод

De-increments the task counter for a specific group.
protected DeincrementGroup ( IWorkGroup group ) : void
group IWorkGroup The group.
Результат void

Dispose() защищенный Метод

Releases unmanaged and - optionally - managed resources.
protected Dispose ( bool disposing ) : void
disposing bool true to release both managed and unmanaged resources; false to release only unmanaged resources.
Результат void

GetScheduledTasks() защищенный Метод

Gets the tasks currently scheduled to this scheduler.
This will always return an empty enumerable, as tasks are launched as soon as they're queued; we also don't want the .net scheduler to mess with our internal queue.
protected GetScheduledTasks ( ) : IEnumerable
Результат IEnumerable

HaveRoomForWorkGroupTask() защищенный Метод

Returns true if the work group has room for a new task
protected HaveRoomForWorkGroupTask ( IWorkGroup group ) : bool
group IWorkGroup The group.
Результат bool

IncrementCounter() защищенный Метод

Increments the counter for the running tasks
protected IncrementCounter ( ) : void
Результат void

IncrementGroup() защищенный Метод

Increments the task count for a specific group
protected IncrementGroup ( IWorkGroup group ) : void
group IWorkGroup The group.
Результат void

QueueTask() защищенный закрытый Метод

Queues a T:System.Threading.Tasks.Task to the scheduler.
protected final QueueTask ( Task task ) : void
task Task The to be queued.
Результат void

RoomForNewWorkGroupTask() публичный Метод

If true, the task scheduler has room for the specified work group task
public RoomForNewWorkGroupTask ( IWorkGroup group ) : RoomForNewTaskResult
group IWorkGroup The group.
Результат RoomForNewTaskResult

SetWaitHandle() защищенный Метод

Sets the wait handle.
protected SetWaitHandle ( IWorkGroup group ) : void
group IWorkGroup The group.
Результат void

SmartThreadPoolTaskScheduler() публичный Метод

Initializes a new instance of the SmartThreadPoolTaskScheduler class.
public SmartThreadPoolTaskScheduler ( ITaskSchedulerConfiguration configuration, IWaitForEventOrCancelThreadPool waitForFreeThread, IMetrics metrics ) : System
configuration ITaskSchedulerConfiguration The configuration.
waitForFreeThread IWaitForEventOrCancelThreadPool The wait for free thread.
metrics IMetrics the metrics factory
Результат System

Start() публичный Метод

Starts this instance.
Start must only be called 1 time
public Start ( ) : void
Результат void

Subscribe() публичный Метод

Informs the scheduler that it has another client connected
public Subscribe ( ) : int
Результат int

ThrowIfDisposed() защищенный Метод

Throws an exception if this instance has been disposed.
protected ThrowIfDisposed ( [ name = "" ) : void
name [ The name.
Результат void

TryExecuteTaskInline() защищенный Метод

Runs the provided task on the current thread.
protected TryExecuteTaskInline ( Task task, bool taskWasPreviouslyQueued ) : bool
task Task The task to be executed.
taskWasPreviouslyQueued bool Ignored.
Результат bool

TryExecuteTaskWrapped() защищенный Метод

A wrapper for executing the task, so that we can return the state information back to the caller
protected TryExecuteTaskWrapped ( Task task, StateInformation state ) : StateInformation
task Task The task.
state StateInformation The state.
Результат StateInformation

UnSubscribe() публичный Метод

Informs the scheduler that a client has disconnected
public UnSubscribe ( int id ) : void
id int The client identifier.
Результат void