TaskScheduler that can execute fibers (yieldable coroutines). More...
Public Member Functions | |
FiberTaskScheduler () | |
Initializes a new instance of the SpicyPixel.Threading.Tasks.FiberTaskScheduler class. More... | |
FiberTaskScheduler (FiberScheduler scheduler) | |
Initializes a new instance of the SpicyPixel.Threading.Tasks.FiberTaskScheduler class. More... | |
void | Dispose () |
Releases all resource used by the SpicyPixel.Threading.Tasks.FiberTaskScheduler object. More... | |
Protected Member Functions | |
override void | QueueTask (Task task) |
Queues a non-blocking task. More... | |
override bool | TryExecuteTaskInline (Task task, bool taskWasPreviouslyQueued) |
Tries to execute the task inline. More... | |
override bool | TryDequeue (Task task) |
Tries to dequeue a task. More... | |
override IEnumerable< Task > | GetScheduledTasks () |
For debugger support only, generates an enumerable of Task instances currently queued to the scheduler waiting to be executed. More... | |
Protected Member Functions inherited from System.Threading.Tasks.TaskScheduler | |
TaskScheduler () | |
bool | TryExecuteTask (Task task) |
Properties | |
CancellationToken | CancellationToken [get] |
Gets the cancellation token set when the scheduler is destroyed. More... | |
FiberScheduler | FiberScheduler [get] |
Gets the fiber scheduler associated with this task scheduler. More... | |
Properties inherited from System.Threading.Tasks.TaskScheduler | |
static TaskScheduler | Default [get] |
static TaskScheduler | Current [get, set] |
int | Id [get] |
virtual int | MaximumConcurrencyLevel [get] |
Additional Inherited Members | |
Static Public Member Functions inherited from System.Threading.Tasks.TaskScheduler | |
static TaskScheduler | FromCurrentSynchronizationContext () |
Events inherited from System.Threading.Tasks.TaskScheduler | |
static EventHandler< UnobservedTaskExceptionEventArgs > | UnobservedTaskException |
Detailed Description
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.
Definition at line 40 of file FiberTaskScheduler.cs.
Constructor & Destructor Documentation
SpicyPixel.Threading.Tasks.FiberTaskScheduler.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.
Definition at line 62 of file FiberTaskScheduler.cs.
SpicyPixel.Threading.Tasks.FiberTaskScheduler.FiberTaskScheduler | ( | FiberScheduler | scheduler | ) |
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.
Definition at line 73 of file FiberTaskScheduler.cs.
Member Function Documentation
void SpicyPixel.Threading.Tasks.FiberTaskScheduler.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.
Definition at line 304 of file FiberTaskScheduler.cs.
|
protectedvirtual |
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.
- Returns
- The scheduled tasks.
Implements System.Threading.Tasks.TaskScheduler.
Definition at line 176 of file FiberTaskScheduler.cs.
|
protectedvirtual |
Queues a non-blocking task.
If the task is queued from the scheduler thread it will begin executing to its first yield immediately.
- Parameters
-
task The non-blocking task to queue.
Implements System.Threading.Tasks.TaskScheduler.
Definition at line 99 of file FiberTaskScheduler.cs.
|
protectedvirtual |
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
.
- Returns
- Returns
true
if the task was dequeued,false
otherwise.
- Parameters
-
task The task to dequeue.
Reimplemented from System.Threading.Tasks.TaskScheduler.
Definition at line 161 of file FiberTaskScheduler.cs.
|
protectedvirtual |
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.
- Returns
- Returns
true
if the task was executed inline,false
otherwise.
- Parameters
-
task The task to execute. taskWasPreviouslyQueued Set to true
if the task was previously queued,false
otherwise.
Implements System.Threading.Tasks.TaskScheduler.
Definition at line 132 of file FiberTaskScheduler.cs.
Property Documentation
|
get |
Gets the cancellation token set when the scheduler is destroyed.
The cancellation token.
Definition at line 51 of file FiberTaskScheduler.cs.
|
get |
Gets the fiber scheduler associated with this task scheduler.
The fiber scheduler.
Definition at line 85 of file FiberTaskScheduler.cs.
The documentation for this class was generated from the following file: