C# Класс SpicyPixel.Threading.Tasks.FiberTaskScheduler

TaskScheduler that can execute fibers (yieldable coroutines). Regular non-blocking tasks can also be scheduled on a FiberTaskScheduler, but YieldableTask have the distinct ability to yield execution.
Наследование: System.Threading.Tasks.TaskScheduler, IDisposable
Показать файл Открыть проект Примеры использования класса

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

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

Releases all resource used by the SpicyPixel.Threading.Tasks.FiberTaskScheduler object.

Call the method when you are finished using the SpicyPixel.Threading.Tasks.FiberTaskScheduler. The method leaves the SpicyPixel.Threading.Tasks.FiberTaskScheduler in an unusable state. After calling the method, you must release all references to the SpicyPixel.Threading.Tasks.FiberTaskScheduler so the garbage collector can reclaim the memory that the SpicyPixel.Threading.Tasks.FiberTaskScheduler was occupying.

FiberTaskScheduler ( ) : System

Initializes a new instance of the SpicyPixel.Threading.Tasks.FiberTaskScheduler class.

Derived classes should invoke EnableQueueTask() in their constructor when ready to begin executing tasks.

FiberTaskScheduler ( FiberScheduler scheduler ) : System

Initializes a new instance of the SpicyPixel.Threading.Tasks.FiberTaskScheduler class.

Derived classes should invoke EnableQueueTask() in their constructor when ready to begin executing tasks.

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

Метод Описание
GetScheduledTasks ( ) : IEnumerable

For debugger support only, generates an enumerable of Task instances currently queued to the scheduler waiting to be executed.

This is not supported and will always return null.

QueueTask ( Task task ) : void

Queues a non-blocking task.

If the task is queued from the scheduler thread it will begin executing to its first yield immediately.

TryDequeue ( Task task ) : bool

Tries to dequeue a task.

Only delay start tasks can be dequeued. Although the Fiber scheduler does delay start tasks queued from a non-scheduler thread, de-queuing is not supported right now and so this method always returns false.

TryExecuteTaskInline ( Task task, bool taskWasPreviouslyQueued ) : bool

Tries to execute the task inline.

Tasks executed on a fiber scheduler have thread affinity and must run on the thread the scheduler was created online. Inline execution will therefore fail if attempted from another thread besides the scheduler thread.

A YieldableTask cannot run inline because yieldable tasks can only be processed by a FiberTaskScheduler when queued.

Because of these restrictions, only standard non-blocking actions invoked on the scheduler thread are eligible for inlining.

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

Метод Описание
Dispose ( bool disposing ) : void

Dispose the scheduler.

When the scheduler is disposed, the CancellationToken is set.

ExecuteTask ( Task task ) : IEnumerator

Execute the specified task as a coroutine.

ExecuteYieldableTask ( YieldableTask task ) : IEnumerator

Execute the specified coroutine associated with a yieldable task.

Any exceptions that occur while executing the fiber will be associated with the specified task and rethrown by the framework.

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

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

Releases all resource used by the SpicyPixel.Threading.Tasks.FiberTaskScheduler object.
Call the method when you are finished using the SpicyPixel.Threading.Tasks.FiberTaskScheduler. The method leaves the SpicyPixel.Threading.Tasks.FiberTaskScheduler in an unusable state. After calling the method, you must release all references to the SpicyPixel.Threading.Tasks.FiberTaskScheduler so the garbage collector can reclaim the memory that the SpicyPixel.Threading.Tasks.FiberTaskScheduler was occupying.
public Dispose ( ) : void
Результат void

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

Initializes a new instance of the SpicyPixel.Threading.Tasks.FiberTaskScheduler class.
Derived classes should invoke EnableQueueTask() in their constructor when ready to begin executing tasks.
public FiberTaskScheduler ( ) : System
Результат System

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

Initializes a new instance of the SpicyPixel.Threading.Tasks.FiberTaskScheduler class.
Derived classes should invoke EnableQueueTask() in their constructor when ready to begin executing tasks.
public FiberTaskScheduler ( FiberScheduler scheduler ) : System
scheduler FiberScheduler
Результат System

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

For debugger support only, generates an enumerable of Task instances currently queued to the scheduler waiting to be executed.
This is not supported and will always return null.
protected GetScheduledTasks ( ) : IEnumerable
Результат IEnumerable

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

Queues a non-blocking task.
If the task is queued from the scheduler thread it will begin executing to its first yield immediately.
protected QueueTask ( Task task ) : void
task Task /// The non-blocking task to queue. ///
Результат void

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

Tries to dequeue a task.
Only delay start tasks can be dequeued. Although the Fiber scheduler does delay start tasks queued from a non-scheduler thread, de-queuing is not supported right now and so this method always returns false.
protected TryDequeue ( Task task ) : bool
task Task /// The task to dequeue. ///
Результат bool

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

Tries to execute the task inline.

Tasks executed on a fiber scheduler have thread affinity and must run on the thread the scheduler was created online. Inline execution will therefore fail if attempted from another thread besides the scheduler thread.

A YieldableTask cannot run inline because yieldable tasks can only be processed by a FiberTaskScheduler when queued.

Because of these restrictions, only standard non-blocking actions invoked on the scheduler thread are eligible for inlining.

protected TryExecuteTaskInline ( Task task, bool taskWasPreviouslyQueued ) : bool
task Task /// The task to execute. ///
taskWasPreviouslyQueued bool /// Set to true if the task was previously queued, false otherwise. ///
Результат bool