Schedules fibers for execution. More...
Public Member Functions | |
void | Run (Fiber fiber) |
Run the blocking scheduler loop and perform the specified number of updates per second. More... | |
virtual void | Run (Fiber fiber, CancellationToken token, float updatesPerSecond=0f) |
Run the blocking scheduler loop and perform the specified number of updates per second. More... | |
void | Run () |
Run the blocking scheduler loop and perform the specified number of updates per second. More... | |
virtual void | Run (CancellationToken token, float updatesPerSecond=0f) |
Run the blocking scheduler loop and perform the specified number of updates per second. More... | |
void | Dispose () |
Releases all resource used by the SpicyPixel.Threading.FiberScheduler object. More... | |
Protected Member Functions | |
FiberScheduler () | |
Initializes a new instance of the SpicyPixel.Threading.FiberScheduler class. More... | |
abstract void | QueueFiber (Fiber fiber) |
Queues the fiber for execution on the scheduler. More... | |
abstract void | AbortRequested (Fiber fiber) |
Invoked when an abort has been requested. More... | |
FiberInstruction | ExecuteFiber (Fiber fiber) |
Executes the fiber until it ends or yields. More... | |
virtual void | Dispose (bool disposing) |
Dispose the scheduler. More... | |
Properties | |
CancellationToken | CancellationToken [get] |
Gets the cancellation token set when the scheduler is destroyed. More... | |
static FiberScheduler | Current [get] |
Gets the default fiber scheduler for the thread. More... | |
Thread | SchedulerThread [get] |
Gets the thread the scheduler is running on. More... | |
bool | AllowInlining [get, set] |
Gets or sets a value indicating whether this SpicyPixel.Threading.FiberScheduler allows inlining. More... | |
Detailed Description
Schedules fibers for execution.
Schedulers are bound to the thread they are created on and they install a SynchronizationContext which is active during execution. Schedulers have an implementation specific update method or run loop. The interface is otherwise thin since schedulers are generally not intended to be used directly. Scheduling work is accomplished by invoking methods on Fiber or SynchronizationContext.
Definition at line 44 of file FiberScheduler.cs.
Constructor & Destructor Documentation
|
protected |
Initializes a new instance of the SpicyPixel.Threading.FiberScheduler class.
Definition at line 184 of file FiberScheduler.cs.
Member Function Documentation
|
protectedpure virtual |
Invoked when an abort has been requested.
This call will only arrive from another thread and it's possible the scheduler may have already dealt with the abort because the state was already changed to AbortRequested before this method is fired. Schedulers must handle that condition.
- Parameters
-
fiber The fiber to be aborted.
Implemented in SpicyPixel.Threading.SystemFiberScheduler, and SpicyPixel.Threading.UnityFiberScheduler.
void SpicyPixel.Threading.FiberScheduler.Dispose | ( | ) |
Releases all resource used by the SpicyPixel.Threading.FiberScheduler object.
Call the method when you are finished using the SpicyPixel.Threading.FiberScheduler. The method leaves the SpicyPixel.Threading.FiberScheduler in an unusable state. After calling the method, you must release all references to the SpicyPixel.Threading.FiberScheduler so the garbage collector can reclaim the memory that the SpicyPixel.Threading.FiberScheduler was occupying.
Definition at line 344 of file FiberScheduler.cs.
|
protectedvirtual |
Dispose the scheduler.
When the scheduler is disposed, the CancellationToken is set.
- Parameters
-
disposing Disposing is true when called manually, false when called by the finalizer.
Reimplemented in SpicyPixel.Threading.SystemFiberScheduler, and SpicyPixel.Threading.UnityFiberScheduler.
Definition at line 360 of file FiberScheduler.cs.
|
protected |
Executes the fiber until it ends or yields.
Custom schedulers will need to invoke this method in order to actually perform the work of the fiber and cause the correct state transitions to occur.
- Returns
- A fiber instruction to be processed by the scheduler.
- Parameters
-
fiber The fiber to execute.
Definition at line 312 of file FiberScheduler.cs.
|
protectedpure virtual |
Queues the fiber for execution on the scheduler.
Fibers queued from the scheduler thread will generally be executed inline whenever possible on most schedulers.
- Returns
- Returns
true
if the fiber was executed inlinefalse
if it was queued.
- Parameters
-
fiber The fiber to queue.
Implemented in SpicyPixel.Threading.SystemFiberScheduler, and SpicyPixel.Threading.UnityFiberScheduler.
void SpicyPixel.Threading.FiberScheduler.Run | ( | Fiber | fiber | ) |
Run the blocking scheduler loop and perform the specified number of updates per second.
Not all schedulers support a blocking run loop that can be invoked by the caller.
- Parameters
-
fiber The initial fiber to start on the scheduler.
Definition at line 212 of file FiberScheduler.cs.
|
virtual |
Run the blocking scheduler loop and perform the specified number of updates per second.
Not all schedulers support a blocking run loop that can be invoked by the caller.
- Parameters
-
fiber The optional fiber to start execution from. If this is null
, the loop will continue to execute until cancelled. Otherwise, the loop will terminate when the fiber terminates.updatesPerSecond Updates to all fibers per second. A value of 0
(the default) will execute fibers any time they are ready to do work instead of waiting to execute on a specific frequency.token A cancellation token that can be used to stop execution.
Reimplemented in SpicyPixel.Threading.SystemFiberScheduler.
Definition at line 235 of file FiberScheduler.cs.
void SpicyPixel.Threading.FiberScheduler.Run | ( | ) |
Run the blocking scheduler loop and perform the specified number of updates per second.
Not all schedulers support a blocking run loop that can be invoked by the caller.
Definition at line 246 of file FiberScheduler.cs.
|
virtual |
Run the blocking scheduler loop and perform the specified number of updates per second.
Not all schedulers support a blocking run loop that can be invoked by the caller.
- Parameters
-
updatesPerSecond Updates to all fibers per second. A value of 0
(the default) will execute fibers any time they are ready to do work instead of waiting to execute on a specific frequency.token A cancellation token that can be used to stop execution.
Definition at line 264 of file FiberScheduler.cs.
Property Documentation
|
getset |
Gets or sets a value indicating whether this SpicyPixel.Threading.FiberScheduler allows inlining.
true
if inlining of tasks on the scheduler thread is allowed; otherwise, false
. Default is true
.
Definition at line 179 of file FiberScheduler.cs.
|
get |
Gets the cancellation token set when the scheduler is destroyed.
The cancellation token.
Definition at line 61 of file FiberScheduler.cs.
|
staticget |
Gets the default fiber scheduler for the thread.
Every thread has a default scheduler which Fiber.Start() uses.
The default fiber scheduler for the thread.
Definition at line 75 of file FiberScheduler.cs.
|
get |
Gets the thread the scheduler is running on.
The scheduler thread.
Definition at line 169 of file FiberScheduler.cs.
The documentation for this class was generated from the following file: