A Fiber is a lightweight means of scheduling work that enables multiple units of processing to execute concurrently by co-operatively sharing execution time on a single thread. More...

+ Collaboration diagram for SpicyPixel.Threading.Fiber:

Public Member Functions

Fiber ContinueWith (IEnumerator continuationCoroutine)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (IEnumerator continuationCoroutine, CancellationToken cancellationToken)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (IEnumerator continuationCoroutine, FiberContinuationOptions continuationOptions)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (IEnumerator continuationCoroutine, FiberScheduler scheduler)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (IEnumerator continuationCoroutine, CancellationToken cancellationToken, FiberContinuationOptions continuationOptions, FiberScheduler scheduler)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (Action< Fiber > continuationAction)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (Action< Fiber > continuationAction, CancellationToken cancellationToken)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (Action< Fiber > continuationAction, FiberContinuationOptions continuationOptions)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (Action< Fiber > continuationAction, FiberScheduler scheduler)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (Action< Fiber > continuationAction, CancellationToken cancellationToken, FiberContinuationOptions continuationOptions, FiberScheduler scheduler)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (Action< Fiber, object > continuationAction, object state)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (Action< Fiber, object > continuationAction, object state, CancellationToken cancellationToken)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (Action< Fiber, object > continuationAction, object state, FiberContinuationOptions continuationOptions)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (Action< Fiber, object > continuationAction, object state, FiberScheduler scheduler)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
Fiber ContinueWith (Action< Fiber, object > continuationAction, object state, CancellationToken cancellationToken, FiberContinuationOptions continuationOptions, FiberScheduler scheduler)
 Creates a continuation that executes asynchronously when the target fiber completes. More...
 
 Fiber (IEnumerator coroutine)
 Initializes a new instance of the SpicyPixel.Threading.Fiber class. More...
 
 Fiber (IEnumerator coroutine, CancellationToken cancellationToken)
 Initializes a new instance of the SpicyPixel.Threading.Fiber class. More...
 
 Fiber (Action action)
 Initializes a new instance of the SpicyPixel.Threading.Fiber class. More...
 
 Fiber (Action action, CancellationToken cancellationToken)
 Initializes a new instance of the SpicyPixel.Threading.Fiber class. More...
 
 Fiber (Action< object > action, object state)
 Initializes a new instance of the SpicyPixel.Threading.Fiber class. More...
 
 Fiber (Action< object > action, object state, CancellationToken cancellationToken)
 Initializes a new instance of the SpicyPixel.Threading.Fiber class. More...
 
 Fiber (Func< FiberInstruction > func)
 Initializes a new instance of the SpicyPixel.Threading.Fiber class. More...
 
 Fiber (Func< FiberInstruction > func, CancellationToken cancellationToken)
 Initializes a new instance of the SpicyPixel.Threading.Fiber class. More...
 
 Fiber (Func< object, FiberInstruction > func, object state)
 Initializes a new instance of the SpicyPixel.Threading.Fiber class. More...
 
 Fiber (Func< object, FiberInstruction > func, object state, CancellationToken cancellationToken)
 Initializes a new instance of the SpicyPixel.Threading.Fiber class. More...
 
void Start ()
 Start executing the fiber using the default scheduler on the thread. More...
 
void Start (FiberScheduler scheduler)
 Start executing the fiber using the specified scheduler. More...
 

Static Public Member Functions

static Fiber Delay (int millisecondsDelay)
 Crates a Fiber that waits for a delay before completing. More...
 
static Fiber Delay (TimeSpan delay)
 Crates a Fiber that waits for a delay before completing. More...
 
static Fiber Delay (TimeSpan delay, CancellationToken cancellationToken)
 Crates a Fiber that waits for a delay before completing. More...
 
static Fiber Delay (int millisecondsDelay, CancellationToken cancellationToken)
 Crates a Fiber that waits for a delay before completing. More...
 
static Fiber Delay (int millisecondsDelay, CancellationToken cancellationToken, FiberScheduler scheduler)
 Crates a Fiber that waits for a delay before completing. More...
 
static Fiber WhenAll (params Fiber[] fibers)
 Returns a fiber that waits on all fibers to complete. More...
 
static Fiber WhenAll (Fiber[] fibers, CancellationToken cancellationToken)
 Returns a fiber that waits on all fibers to complete. More...
 
static Fiber WhenAll (Fiber[] fibers, TimeSpan timeout)
 Returns a fiber that waits on all fibers to complete. More...
 
static Fiber WhenAll (Fiber[] fibers, int millisecondsTimeout)
 Returns a fiber that waits on all fibers to complete. More...
 
static Fiber WhenAll (Fiber[] fibers, int millisecondsTimeout, CancellationToken cancellationToken)
 Returns a fiber that waits on all fibers to complete. More...
 
static Fiber WhenAll (Fiber[] fibers, int millisecondsTimeout, CancellationToken cancellationToken, FiberScheduler scheduler)
 Returns a fiber that waits on all fibers to complete. More...
 
static Fiber WhenAll (IEnumerable< Fiber > fibers, int millisecondsTimeout, CancellationToken cancellationToken, FiberScheduler scheduler)
 Returns a fiber that waits on all fibers to complete. More...
 
static Fiber WhenAny (params Fiber[] fibers)
 Returns a fiber that completes when any fiber finishes. More...
 
static Fiber WhenAny (Fiber[] fibers, CancellationToken cancellationToken)
 Returns a fiber that completes when any fiber finishes. More...
 
static Fiber WhenAny (Fiber[] fibers, TimeSpan timeout)
 Returns a fiber that completes when any fiber finishes. More...
 
static Fiber WhenAny (Fiber[] fibers, int millisecondsTimeout)
 Returns a fiber that completes when any fiber finishes. More...
 
static Fiber WhenAny (Fiber[] fibers, int millisecondsTimeout, CancellationToken cancellationToken)
 Returns a fiber that completes when any fiber finishes. More...
 
static Fiber WhenAny (Fiber[] fibers, int millisecondsTimeout, CancellationToken cancellationToken, FiberScheduler scheduler)
 Returns a fiber that completes when any fiber finishes. More...
 
static Fiber WhenAny (IEnumerable< Fiber > fibers, int millisecondsTimeout, CancellationToken cancellationToken, FiberScheduler scheduler)
 Returns a fiber that completes when any fiber finishes. More...
 

Properties

static Fiber CurrentFiber [get]
 Gets the currently executing fiber on this thread. More...
 
static FiberFactory Factory [get]
 Gets the default factory for creating fibers. More...
 
IDictionary< string, object > Properties [get]
 Gets user-defined properties associated with the fiber. More...
 
string Name [get, set]
 Gets or sets the name. More...
 
object ResultAsObject [get, set]
 Gets or sets the result of the fiber's execution as an object. More...
 
bool IsCanceled [get]
 Gets a value indicating whether this instance is canceled. More...
 
bool IsCompleted [get]
 Gets a value indicating whether this instance is completed. More...
 
bool IsFaulted [get]
 Gets a value indicating whether this instance is faulted. More...
 
Exception Exception [get]
 Gets the exception that led to the Faulted state. More...
 
FiberStatus Status [get, set]
 Gets or sets the state of the fiber. More...
 
Fiber Antecedent [get]
 Gets the antecedent, which is the fiber that this fiber was dependent upon for starting execution. More...
 
CancellationToken CancellationToken [get]
 Gets the cancellation token for the Fiber. More...
 
int Id [get]
 Gets the thread unique identifier for the fiber. More...
 

Detailed Description

A Fiber is a lightweight means of scheduling work that enables multiple units of processing to execute concurrently by co-operatively sharing execution time on a single thread.

Fibers are also known as "micro-threads" and can be implemented using programming language facilities such as "coroutines".

Fibers simplify many concurrency issues generally associated with multithreading because a given fiber has complete control over when it yields execution to another fiber. A fiber does not need to manage resource locking or handle changing data in the same way as a thread does because access to a resource is never preempted by another fiber without co-operation.

Fibers can improve performance in certain applications with concurrency requirements. Because many fibers can run on a thread, this can relieve pressure on precious resources in the thread pool and reduce latency. Additionally, some applications have concurrent, interdependent processes that naturally lend themselves to co-operative scheduling which can result in greater efficiency when the application manages the context switch instead of a pre-emptive scheduler.

Fibers can also be a convenient way to express a state machine. The master fiber implementing the machine can test state conditions, start new fibers for state actions, yield to an action fiber until it completes, and then handle the transition out of the state and into a new state.

Definition at line 8 of file Fiber.ContinueWith.cs.

Constructor & Destructor Documentation

SpicyPixel.Threading.Fiber.Fiber ( IEnumerator  coroutine)

Initializes a new instance of the SpicyPixel.Threading.Fiber class.

Parameters
coroutineA couroutine to execute on the fiber.

Definition at line 312 of file Fiber.cs.

SpicyPixel.Threading.Fiber.Fiber ( IEnumerator  coroutine,
CancellationToken  cancellationToken 
)

Initializes a new instance of the SpicyPixel.Threading.Fiber class.

Parameters
coroutineA couroutine to execute on the fiber.
cancellationTokenCancellation token.

Definition at line 323 of file Fiber.cs.

SpicyPixel.Threading.Fiber.Fiber ( Action  action)

Initializes a new instance of the SpicyPixel.Threading.Fiber class.

Parameters
actionA non-blocking action to execute on the fiber.

Definition at line 336 of file Fiber.cs.

SpicyPixel.Threading.Fiber.Fiber ( Action  action,
CancellationToken  cancellationToken 
)

Initializes a new instance of the SpicyPixel.Threading.Fiber class.

Parameters
actionA non-blocking action to execute on the fiber.
cancellationTokenCancellation token.

Definition at line 347 of file Fiber.cs.

SpicyPixel.Threading.Fiber.Fiber ( Action< object >  action,
object  state 
)

Initializes a new instance of the SpicyPixel.Threading.Fiber class.

Parameters
actionA non-blocking action to execute on the fiber.
stateState to pass to the action.

Definition at line 363 of file Fiber.cs.

SpicyPixel.Threading.Fiber.Fiber ( Action< object >  action,
object  state,
CancellationToken  cancellationToken 
)

Initializes a new instance of the SpicyPixel.Threading.Fiber class.

Parameters
actionA non-blocking action to execute on the fiber.
stateState to pass to the action.
cancellationTokenCancellation token.

Definition at line 377 of file Fiber.cs.

SpicyPixel.Threading.Fiber.Fiber ( Func< FiberInstruction func)

Initializes a new instance of the SpicyPixel.Threading.Fiber class.

Parameters
funcA non-blocking function that returns a FiberInstruction when complete.

Definition at line 391 of file Fiber.cs.

SpicyPixel.Threading.Fiber.Fiber ( Func< FiberInstruction func,
CancellationToken  cancellationToken 
)

Initializes a new instance of the SpicyPixel.Threading.Fiber class.

Parameters
funcA non-blocking function that returns a FiberInstruction when complete.
cancellationTokenCancellation token.

Definition at line 402 of file Fiber.cs.

SpicyPixel.Threading.Fiber.Fiber ( Func< object, FiberInstruction func,
object  state 
)

Initializes a new instance of the SpicyPixel.Threading.Fiber class.

Parameters
funcA non-blocking function that returns a FiberInstruction when complete.
stateState to pass to the function.

Definition at line 418 of file Fiber.cs.

SpicyPixel.Threading.Fiber.Fiber ( Func< object, FiberInstruction func,
object  state,
CancellationToken  cancellationToken 
)

Initializes a new instance of the SpicyPixel.Threading.Fiber class.

Parameters
funcA non-blocking function that returns a FiberInstruction when complete.
stateState to pass to the function.
cancellationTokenCancellation token.

Definition at line 432 of file Fiber.cs.

Member Function Documentation

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( IEnumerator  continuationCoroutine)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationCoroutineContinuation coroutine.

Definition at line 15 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( IEnumerator  continuationCoroutine,
CancellationToken  cancellationToken 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationCoroutineContinuation coroutine.
cancellationTokenCancellation token.

Definition at line 26 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( IEnumerator  continuationCoroutine,
FiberContinuationOptions  continuationOptions 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationCoroutineContinuation coroutine.
continuationOptionsContinuation options.

Definition at line 37 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( IEnumerator  continuationCoroutine,
FiberScheduler  scheduler 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationCoroutineContinuation coroutine.
schedulerScheduler.

Definition at line 48 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( IEnumerator  continuationCoroutine,
CancellationToken  cancellationToken,
FiberContinuationOptions  continuationOptions,
FiberScheduler  scheduler 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationCoroutineContinuation coroutine.
cancellationTokenCancellation token.
continuationOptionsContinuation options.
schedulerScheduler.

Definition at line 61 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( Action< Fiber continuationAction)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationActionContinuation action.

Definition at line 95 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( Action< Fiber continuationAction,
CancellationToken  cancellationToken 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationActionContinuation action.
cancellationTokenCancellation token.

Definition at line 106 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( Action< Fiber continuationAction,
FiberContinuationOptions  continuationOptions 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationActionContinuation action.
continuationOptionsContinuation options.

Definition at line 117 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( Action< Fiber continuationAction,
FiberScheduler  scheduler 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationActionContinuation action.
schedulerScheduler.

Definition at line 128 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( Action< Fiber continuationAction,
CancellationToken  cancellationToken,
FiberContinuationOptions  continuationOptions,
FiberScheduler  scheduler 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationActionContinuation action.
cancellationTokenCancellation token.
continuationOptionsContinuation options.
schedulerScheduler.

Definition at line 141 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( Action< Fiber, object >  continuationAction,
object  state 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationActionContinuation action.
stateState.

Definition at line 153 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( Action< Fiber, object >  continuationAction,
object  state,
CancellationToken  cancellationToken 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationActionContinuation action.
stateState.
cancellationTokenCancellation token.

Definition at line 165 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( Action< Fiber, object >  continuationAction,
object  state,
FiberContinuationOptions  continuationOptions 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationActionContinuation action.
stateState.
continuationOptionsContinuation options.

Definition at line 177 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( Action< Fiber, object >  continuationAction,
object  state,
FiberScheduler  scheduler 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationActionContinuation action.
stateState.
schedulerScheduler.

Definition at line 189 of file Fiber.ContinueWith.cs.

Fiber SpicyPixel.Threading.Fiber.ContinueWith ( Action< Fiber, object >  continuationAction,
object  state,
CancellationToken  cancellationToken,
FiberContinuationOptions  continuationOptions,
FiberScheduler  scheduler 
)

Creates a continuation that executes asynchronously when the target fiber completes.

Returns
A fiber that executes when the target fiber completes.
Parameters
continuationActionContinuation action.
stateState.
cancellationTokenCancellation token.
continuationOptionsContinuation options.
schedulerScheduler.

Definition at line 203 of file Fiber.ContinueWith.cs.

static Fiber SpicyPixel.Threading.Fiber.Delay ( int  millisecondsDelay)
static

Crates a Fiber that waits for a delay before completing.

Parameters
millisecondsDelayMilliseconds to delay.

Definition at line 13 of file Fiber.Delay.cs.

static Fiber SpicyPixel.Threading.Fiber.Delay ( TimeSpan  delay)
static

Crates a Fiber that waits for a delay before completing.

Parameters
delayTime span to delay.

Definition at line 22 of file Fiber.Delay.cs.

static Fiber SpicyPixel.Threading.Fiber.Delay ( TimeSpan  delay,
CancellationToken  cancellationToken 
)
static

Crates a Fiber that waits for a delay before completing.

Parameters
delayTime span to delay.
cancellationTokenCancellation token.

Definition at line 32 of file Fiber.Delay.cs.

static Fiber SpicyPixel.Threading.Fiber.Delay ( int  millisecondsDelay,
CancellationToken  cancellationToken 
)
static

Crates a Fiber that waits for a delay before completing.

Parameters
millisecondsDelayMilliseconds to delay.
cancellationTokenCancellation token.

Definition at line 42 of file Fiber.Delay.cs.

static Fiber SpicyPixel.Threading.Fiber.Delay ( int  millisecondsDelay,
CancellationToken  cancellationToken,
FiberScheduler  scheduler 
)
static

Crates a Fiber that waits for a delay before completing.

Parameters
millisecondsDelayMilliseconds to delay.
cancellationTokenCancellation token.
schedulerScheduler.

Definition at line 53 of file Fiber.Delay.cs.

void SpicyPixel.Threading.Fiber.Start ( )

Start executing the fiber using the default scheduler on the thread.

Definition at line 443 of file Fiber.cs.

void SpicyPixel.Threading.Fiber.Start ( FiberScheduler  scheduler)

Start executing the fiber using the specified scheduler.

This method is safe to call from any thread even if different than the scheduler execution thread.

Parameters
schedulerThe scheduler to start the fiber on.

Definition at line 458 of file Fiber.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAll ( params Fiber[]  fibers)
static

Returns a fiber that waits on all fibers to complete.

Fiber.ResultAsObject will be true if all fibers complete successfully or false if cancelled or timeout.

Returns
A fiber that waits on all fibers to complete.
Parameters
fibersFibers to wait for completion.

Definition at line 20 of file Fiber.WhenAll.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAll ( Fiber[]  fibers,
CancellationToken  cancellationToken 
)
static

Returns a fiber that waits on all fibers to complete.

Fiber.ResultAsObject will be true if all fibers complete successfully or false if cancelled or timeout.

Returns
A fiber that waits on all fibers to complete.
Parameters
fibersFibers to wait for completion.
cancellationTokenCancellation token.

Definition at line 35 of file Fiber.WhenAll.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAll ( Fiber[]  fibers,
TimeSpan  timeout 
)
static

Returns a fiber that waits on all fibers to complete.

Fiber.ResultAsObject will be true if all fibers complete successfully or false if cancelled or timeout.

Returns
A fiber that waits on all fibers to complete.
Parameters
fibersFibers to wait for completion.
timeoutTimeout.

Definition at line 50 of file Fiber.WhenAll.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAll ( Fiber[]  fibers,
int  millisecondsTimeout 
)
static

Returns a fiber that waits on all fibers to complete.

Fiber.ResultAsObject will be true if all fibers complete successfully or false if cancelled or timeout.

Returns
A fiber that waits on all fibers to complete.
Parameters
fibersFibers to wait for completion.
millisecondsTimeoutMilliseconds timeout.

Definition at line 65 of file Fiber.WhenAll.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAll ( Fiber[]  fibers,
int  millisecondsTimeout,
CancellationToken  cancellationToken 
)
static

Returns a fiber that waits on all fibers to complete.

Fiber.ResultAsObject will be true if all fibers complete successfully or false if cancelled or timeout.

Returns
A fiber that waits on all fibers to complete.
Parameters
fibersFibers to wait for completion.
millisecondsTimeoutMilliseconds timeout.
cancellationTokenCancellation token.

Definition at line 81 of file Fiber.WhenAll.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAll ( Fiber[]  fibers,
int  millisecondsTimeout,
CancellationToken  cancellationToken,
FiberScheduler  scheduler 
)
static

Returns a fiber that waits on all fibers to complete.

Fiber.ResultAsObject will be true if all fibers complete successfully or false if cancelled or timeout.

Returns
A fiber that waits on all fibers to complete.
Parameters
fibersFibers to wait for completion.
millisecondsTimeoutMilliseconds timeout.
cancellationTokenCancellation token.
schedulerScheduler.

Definition at line 98 of file Fiber.WhenAll.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAll ( IEnumerable< Fiber fibers,
int  millisecondsTimeout,
CancellationToken  cancellationToken,
FiberScheduler  scheduler 
)
static

Returns a fiber that waits on all fibers to complete.

Fiber.ResultAsObject will be true if all fibers complete successfully or false if cancelled or timeout.

Returns
A fiber that waits on all fibers to complete.
Parameters
fibersFibers to wait for completion.
millisecondsTimeoutMilliseconds timeout.
cancellationTokenCancellation token.
schedulerScheduler.

Definition at line 123 of file Fiber.WhenAll.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAny ( params Fiber[]  fibers)
static

Returns a fiber that completes when any fiber finishes.

Fiber.ResultAsObject will be the Fiber that completed.

Returns
A fiber that completes when any fiber finishes.
Parameters
fibersFibers to wait for completion.

Definition at line 19 of file Fiber.WhenAny.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAny ( Fiber[]  fibers,
CancellationToken  cancellationToken 
)
static

Returns a fiber that completes when any fiber finishes.

Fiber.ResultAsObject will be the Fiber that completed.

Returns
A fiber that completes when any fiber finishes.
Parameters
fibersFibers to wait for completion.
cancellationTokenCancellation token.

Definition at line 33 of file Fiber.WhenAny.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAny ( Fiber[]  fibers,
TimeSpan  timeout 
)
static

Returns a fiber that completes when any fiber finishes.

Fiber.ResultAsObject will be the Fiber that completed.

Returns
A fiber that completes when any fiber finishes.
Parameters
fibersFibers to wait for completion.
timeoutTimeout.

Definition at line 47 of file Fiber.WhenAny.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAny ( Fiber[]  fibers,
int  millisecondsTimeout 
)
static

Returns a fiber that completes when any fiber finishes.

Fiber.ResultAsObject will be the Fiber that completed.

Returns
A fiber that completes when any fiber finishes.
Parameters
fibersFibers to wait for completion.
millisecondsTimeoutMilliseconds timeout.

Definition at line 61 of file Fiber.WhenAny.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAny ( Fiber[]  fibers,
int  millisecondsTimeout,
CancellationToken  cancellationToken 
)
static

Returns a fiber that completes when any fiber finishes.

Fiber.ResultAsObject will be the Fiber that completed.

Returns
A fiber that completes when any fiber finishes.
Parameters
fibersFibers to wait for completion.
millisecondsTimeoutMilliseconds timeout.
cancellationTokenCancellation token.

Definition at line 76 of file Fiber.WhenAny.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAny ( Fiber[]  fibers,
int  millisecondsTimeout,
CancellationToken  cancellationToken,
FiberScheduler  scheduler 
)
static

Returns a fiber that completes when any fiber finishes.

Fiber.ResultAsObject will be the Fiber that completed.

Returns
A fiber that completes when any fiber finishes.
Parameters
fibersFibers to wait for completion.
millisecondsTimeoutMilliseconds timeout.
cancellationTokenCancellation token.
schedulerScheduler.

Definition at line 92 of file Fiber.WhenAny.cs.

static Fiber SpicyPixel.Threading.Fiber.WhenAny ( IEnumerable< Fiber fibers,
int  millisecondsTimeout,
CancellationToken  cancellationToken,
FiberScheduler  scheduler 
)
static

Returns a fiber that completes when any fiber finishes.

Fiber.ResultAsObject will be the Fiber that completed.

Returns
A fiber that completes when any fiber finishes.
Parameters
fibersFibers to wait for completion.
millisecondsTimeoutMilliseconds timeout.
cancellationTokenCancellation token.
schedulerScheduler.

Definition at line 116 of file Fiber.WhenAny.cs.

Property Documentation

Fiber SpicyPixel.Threading.Fiber.Antecedent
get

Gets the antecedent, which is the fiber that this fiber was dependent upon for starting execution.

The antecedent provides access to a prior result through GetAsResultObject().

The antecedent.

Definition at line 251 of file Fiber.cs.

CancellationToken SpicyPixel.Threading.Fiber.CancellationToken
get

Gets the cancellation token for the Fiber.

The token is made available because coroutines don't have a convenient way to get at it otherwise. This way, an executing coroutine can:

Fiber.CurrentFiber.CancellationToken.ThrowIfCancellationRequested();

The cancellation token.

Definition at line 267 of file Fiber.cs.

Fiber SpicyPixel.Threading.Fiber.CurrentFiber
staticget

Gets the currently executing fiber on this thread.

The currently executing fiber on this thread.

Definition at line 107 of file Fiber.cs.

Exception SpicyPixel.Threading.Fiber.Exception
get

Gets the exception that led to the Faulted state.

The exception.

Definition at line 227 of file Fiber.cs.

FiberFactory SpicyPixel.Threading.Fiber.Factory
staticget

Gets the default factory for creating fibers.

The factory.

Definition at line 120 of file Fiber.cs.

int SpicyPixel.Threading.Fiber.Id
get

Gets the thread unique identifier for the fiber.

The identifier.

Definition at line 304 of file Fiber.cs.

bool SpicyPixel.Threading.Fiber.IsCanceled
get

Gets a value indicating whether this instance is canceled.

true if this instance is canceled; otherwise, false.

Definition at line 188 of file Fiber.cs.

bool SpicyPixel.Threading.Fiber.IsCompleted
get

Gets a value indicating whether this instance is completed.

"Completed" means:

true if this instance is completed; otherwise, false.

Definition at line 204 of file Fiber.cs.

bool SpicyPixel.Threading.Fiber.IsFaulted
get

Gets a value indicating whether this instance is faulted.

See Fiber.Exception for the exception causing the fault.

true if this instance is faulted; otherwise, false.

Definition at line 217 of file Fiber.cs.

string SpicyPixel.Threading.Fiber.Name
getset

Gets or sets the name.

The name.

Definition at line 176 of file Fiber.cs.

IDictionary<string, object> SpicyPixel.Threading.Fiber.Properties
get

Gets user-defined properties associated with the fiber.

Similar to thread local storage, callers may associate data with a fiber. A FiberStorage<T> class could retrieve data from the this property collection on the CurrentFiber.

Schedulers may also use this storage to associate additional data needed to perform scheduling operations.

The properties.

Definition at line 150 of file Fiber.cs.

object SpicyPixel.Threading.Fiber.ResultAsObject
getset

Gets or sets the result of the fiber's execution as an object.

The result of the fiber's execution as an object.

Definition at line 182 of file Fiber.cs.

FiberStatus SpicyPixel.Threading.Fiber.Status
getset

Gets or sets the state of the fiber.

The state of the fiber (Unstarted, Running, Stopped).

Definition at line 238 of file Fiber.cs.


The documentation for this class was generated from the following files: