Photon Server API
Public Member Functions | Properties | List of all members
ExitGames.Concurrency.Fibers.StubFiber Class Reference

StubFiber does not use a backing thread or a thread pool for execution. Actions are added to pending lists for execution. These actions can be executed synchronously by the calling thread. This class is not thread safe and should not be used in production code. More...

Inheritance diagram for ExitGames.Concurrency.Fibers.StubFiber:
ExitGames.Concurrency.Fibers.IFiber ExitGames.Concurrency.Core.ISubscriptionRegistry ExitGames.Concurrency.Core.IExecutionContext ExitGames.Concurrency.Core.IScheduler

Public Member Functions

void Start ()
 No Op More...
 
void Dispose ()
 Clears all subscriptions, scheduled, and pending actions. More...
 
void Enqueue (Action action)
 Enqueue a single action. More...
 
void RegisterSubscription (IDisposable toAdd)
 
bool DeregisterSubscription (IDisposable toRemove)
 
IDisposable Schedule (Action action, long firstInMs)
 Adds a scheduled action to the list. More...
 
IDisposable ScheduleOnInterval (Action action, long firstInMs, long regularInMs)
 Adds scheduled action to list. More...
 
void ExecuteAllPendingUntilEmpty ()
 Execute all actions in the pending list. If any of the executed actions enqueue more actions, execute those as well. More...
 
void ExecuteAllPending ()
 Execute all actions in the pending list. More...
 
void ExecuteAllScheduled ()
 Execute all actions in the scheduled list. More...
 

Properties

int NumSubscriptions [get]
 
List< IDisposable > Subscriptions [get]
 All subscriptions. More...
 
List< Action > Pending [get]
 All pending actions. More...
 
List< StubScheduledActionScheduled [get]
 All scheduled actions. More...
 
bool ExecutePendingImmediately [get, set]
 If true events will be executed immediately rather than added to the pending list. More...
 

Detailed Description

StubFiber does not use a backing thread or a thread pool for execution. Actions are added to pending lists for execution. These actions can be executed synchronously by the calling thread. This class is not thread safe and should not be used in production code.

The class is typically used for testing asynchronous code to make it completely synchronous and deterministic.

Member Function Documentation

bool ExitGames.Concurrency.Fibers.StubFiber.DeregisterSubscription ( IDisposable  toRemove)
inline

summary> Number of subscriptions. /summary>

Implements ExitGames.Concurrency.Core.ISubscriptionRegistry.

void ExitGames.Concurrency.Fibers.StubFiber.Dispose ( )
inline

Clears all subscriptions, scheduled, and pending actions.

void ExitGames.Concurrency.Fibers.StubFiber.Enqueue ( Action  action)
inline

Enqueue a single action.

Parameters
action

summary> Register subscription to be unsubcribed from when the fiber is disposed. /summary> param name="toAdd">

Implements ExitGames.Concurrency.Core.IExecutionContext.

void ExitGames.Concurrency.Fibers.StubFiber.ExecuteAllPending ( )
inline

Execute all actions in the pending list.

void ExitGames.Concurrency.Fibers.StubFiber.ExecuteAllPendingUntilEmpty ( )
inline

Execute all actions in the pending list. If any of the executed actions enqueue more actions, execute those as well.

void ExitGames.Concurrency.Fibers.StubFiber.ExecuteAllScheduled ( )
inline

Execute all actions in the scheduled list.

void ExitGames.Concurrency.Fibers.StubFiber.RegisterSubscription ( IDisposable  toAdd)
inline

summary> Deregister a subscription. /summary> param name="toRemove">

returns>

Implements ExitGames.Concurrency.Core.ISubscriptionRegistry.

IDisposable ExitGames.Concurrency.Fibers.StubFiber.Schedule ( Action  action,
long  firstInMs 
)
inline

Adds a scheduled action to the list.

Parameters
action
firstInMs
Returns

Implements ExitGames.Concurrency.Core.IScheduler.

IDisposable ExitGames.Concurrency.Fibers.StubFiber.ScheduleOnInterval ( Action  action,
long  firstInMs,
long  regularInMs 
)
inline

Adds scheduled action to list.

Parameters
action
firstInMs
regularInMs
Returns

Implements ExitGames.Concurrency.Core.IScheduler.

void ExitGames.Concurrency.Fibers.StubFiber.Start ( )
inline

Property Documentation

bool ExitGames.Concurrency.Fibers.StubFiber.ExecutePendingImmediately
getset

If true events will be executed immediately rather than added to the pending list.

int ExitGames.Concurrency.Fibers.StubFiber.NumSubscriptions
get
List<Action> ExitGames.Concurrency.Fibers.StubFiber.Pending
get

All pending actions.

List<StubScheduledAction> ExitGames.Concurrency.Fibers.StubFiber.Scheduled
get

All scheduled actions.

List<IDisposable> ExitGames.Concurrency.Fibers.StubFiber.Subscriptions
get

All subscriptions.