Photon Server API Documentation v5.0RC1

Public Member Functions | Protected Attributes | Properties | List of all members
ExitGames.Concurrency.Fibers.PoolFiber Class Reference

Fiber that uses a thread pool for execution. More...

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

Public Member Functions

 PoolFiber (IThreadPool pool, IExecutor executor)
 Construct new instance. More...
 
 PoolFiber (IExecutor executor)
 Create a pool fiber with the default thread pool. More...
 
 PoolFiber ()
 Create a pool fiber with the default thread pool and default executor. More...
 
void Enqueue (Action action)
 Enqueue a single action. More...
 
void Enqueue (IFiberAction action)
 Enqueue a single action. More...
 
void RegisterSubscription (IDisposable toAdd)
 Register subscription to be unsubscribed from when the fiber is disposed. More...
 
bool DeregisterSubscription (IDisposable toRemove)
 Deregister a subscription. More...
 
IDisposable Schedule (IFiberAction action, int firstInMs)
 IScheduler.Schedule(IFiberAction,long) More...
 
IDisposable ScheduleOnInterval (IFiberAction action, int firstInMs, int regularInMs)
 IScheduler.ScheduleOnInterval(Action,long,long) More...
 
IDisposable Schedule (Action action, int firstInMs)
 Schedules an action to be executed once. More...
 
IDisposable ScheduleOnInterval (Action action, int firstInMs, int regularInMs)
 Schedule an action to be executed on a recurring interval. More...
 
void Start ()
 Start consuming actions. More...
 
void Stop ()
 Stop consuming actions. More...
 
void Dispose ()
 Stops the fiber. More...
 

Protected Attributes

readonly object lock = new object()
 
int started = (int)ExecutionState.Created
 

Properties

ICounter CounterItemsInQueue [get, set]
 
ICounter CounterItemsInExecution [get, set]
 
ICounter CounterEnqueue [get, set]
 
ICounter CounterDequeue [get, set]
 
int NumSubscriptions [get]
 Number of subscriptions. More...
 

Detailed Description

Fiber that uses a thread pool for execution.

Constructor & Destructor Documentation

◆ PoolFiber() [1/3]

ExitGames.Concurrency.Fibers.PoolFiber.PoolFiber ( IThreadPool  pool,
IExecutor  executor 
)
inline

Construct new instance.

Parameters
pool
executor

◆ PoolFiber() [2/3]

ExitGames.Concurrency.Fibers.PoolFiber.PoolFiber ( IExecutor  executor)
inline

Create a pool fiber with the default thread pool.

◆ PoolFiber() [3/3]

ExitGames.Concurrency.Fibers.PoolFiber.PoolFiber ( )
inline

Create a pool fiber with the default thread pool and default executor.

Member Function Documentation

◆ DeregisterSubscription()

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

Deregister a subscription.

Parameters
toRemove
Returns

Implements ExitGames.Concurrency.Core.ISubscriptionRegistry.

◆ Dispose()

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

Stops the fiber.

◆ Enqueue() [1/2]

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

Enqueue a single action.

Parameters
action

Implements ExitGames.Concurrency.Core.IExecutionContext.

◆ Enqueue() [2/2]

void ExitGames.Concurrency.Fibers.PoolFiber.Enqueue ( IFiberAction  action)
inline

Enqueue a single action.

Parameters
action

Implements ExitGames.Concurrency.Core.IExecutionContext.

◆ RegisterSubscription()

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

Register subscription to be unsubscribed from when the fiber is disposed.

Parameters
toAdd

Implements ExitGames.Concurrency.Core.ISubscriptionRegistry.

◆ Schedule() [1/2]

IDisposable ExitGames.Concurrency.Fibers.PoolFiber.Schedule ( Action  action,
int  firstInMs 
)
inline

Schedules an action to be executed once.

Parameters
action
firstInMs
Returns
a handle to cancel the timer.

Implements ExitGames.Concurrency.Core.IScheduler.

◆ Schedule() [2/2]

IDisposable ExitGames.Concurrency.Fibers.PoolFiber.Schedule ( IFiberAction  action,
int  firstInMs 
)
inline

IScheduler.Schedule(IFiberAction,long)

Parameters
action
firstInMs
Returns

Implements ExitGames.Concurrency.Core.IScheduler.

◆ ScheduleOnInterval() [1/2]

IDisposable ExitGames.Concurrency.Fibers.PoolFiber.ScheduleOnInterval ( Action  action,
int  firstInMs,
int  regularInMs 
)
inline

Schedule an action to be executed on a recurring interval.

Parameters
action
firstInMs
regularInMs
Returns
a handle to cancel the timer.

Implements ExitGames.Concurrency.Core.IScheduler.

◆ ScheduleOnInterval() [2/2]

IDisposable ExitGames.Concurrency.Fibers.PoolFiber.ScheduleOnInterval ( IFiberAction  action,
int  firstInMs,
int  regularInMs 
)
inline

IScheduler.ScheduleOnInterval(Action,long,long)

Parameters
action
firstInMs
regularInMs
Returns

Implements ExitGames.Concurrency.Core.IScheduler.

◆ Start()

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

Start consuming actions.

Implements ExitGames.Concurrency.Fibers.IFiber.

◆ Stop()

void ExitGames.Concurrency.Fibers.PoolFiber.Stop ( )
inline

Stop consuming actions.

Member Data Documentation

◆ lock

readonly object ExitGames.Concurrency.Fibers.PoolFiber.lock = new object()
protected

◆ started

int ExitGames.Concurrency.Fibers.PoolFiber.started = (int)ExecutionState.Created
protected

Property Documentation

◆ CounterDequeue

ICounter ExitGames.Concurrency.Fibers.PoolFiber.CounterDequeue
getset

◆ CounterEnqueue

ICounter ExitGames.Concurrency.Fibers.PoolFiber.CounterEnqueue
getset

◆ CounterItemsInExecution

ICounter ExitGames.Concurrency.Fibers.PoolFiber.CounterItemsInExecution
getset

◆ CounterItemsInQueue

ICounter ExitGames.Concurrency.Fibers.PoolFiber.CounterItemsInQueue
getset

◆ NumSubscriptions

int ExitGames.Concurrency.Fibers.PoolFiber.NumSubscriptions
get

Number of subscriptions.