Quantum 3 3.1.0

Public Member Functions | Public Attributes | Properties | List of all members
Photon.Realtime.AsyncOperationHandler Class Reference

The operation handler is used to monitor the Photon Realtime operation callbacks for an async task. More...

Inherits IDisposable.

Public Member Functions

 AsyncOperationHandler ()
 Create a new operation handler without a timeout. More...
 
 AsyncOperationHandler (float operationTimeoutSec)
 Create a new operation handler with a timeout. More...
 
void Dispose ()
 Dispose the handler and dispose all its Disposables. More...
 
void SetException (Exception e)
 Set an exception as result and complete the operation handler. More...
 
void SetResult (short result)
 Set the result and complete the operation handler. More...
 

Public Attributes

TaskCompletionSource< short > CompletionSource => _result
 The completion source to trigger by operation callbacks. More...
 
bool IsCancellationRequested => _cancellation == null ? false : _cancellation.IsCancellationRequested
 Returns if cancellation has been requested. More...
 
Task< short > Task => _result.Task
 Returns the task to complete. More...
 
CancellationToken Token => _cancellation == null ? CancellationToken.None : _cancellation.Token
 The cancellation token for the operation timeout, will return CancellationToken.None if no timeout is set. More...
 

Properties

ConcurrentQueue< IDisposable > Disposables [get]
 A collection of additional objects or callbacks that need to be disposed once the operation handler is done. For example subscriptions to RealtimeClient.CallbackMessage. More...
 
string Name [get, set]
 The name of the operation handler, only set in DEBUG build configuration. More...
 

Detailed Description

The operation handler is used to monitor the Photon Realtime operation callbacks for an async task.

The handler completes its task from inside the client's dispatch (i.e. while the peer holds its dispatch lock). The completion source therefore uses RunContinuationsAsynchronously: awaiting code is never run inline on the dispatching thread, so it can't deadlock by (synchronously) waiting for something that needs the dispatch lock (e.g. Disconnect(), Connect() or another Service() call). Exception: Unity WebGL, as it's single threaded anyways.

Constructor & Destructor Documentation

◆ AsyncOperationHandler() [1/2]

Photon.Realtime.AsyncOperationHandler.AsyncOperationHandler ( float  operationTimeoutSec)
inline

Create a new operation handler with a timeout.

A timeout only faults the Task. Without a service task (AsyncExtensions.CreateServiceTask), dispose the handler yourself.

Parameters
operationTimeoutSecOperation timeout in seconds.

◆ AsyncOperationHandler() [2/2]

Photon.Realtime.AsyncOperationHandler.AsyncOperationHandler ( )
inline

Create a new operation handler without a timeout.

Member Function Documentation

◆ SetResult()

void Photon.Realtime.AsyncOperationHandler.SetResult ( short  result)
inline

Set the result and complete the operation handler.

Parameters
resultResult.

◆ SetException()

void Photon.Realtime.AsyncOperationHandler.SetException ( Exception  e)
inline

Set an exception as result and complete the operation handler.

Parameters
eException to raise.

◆ Dispose()

void Photon.Realtime.AsyncOperationHandler.Dispose ( )
inline

Dispose the handler and dispose all its Disposables.

Member Data Documentation

◆ Task

Task<short> Photon.Realtime.AsyncOperationHandler.Task => _result.Task

Returns the task to complete.

◆ CompletionSource

TaskCompletionSource<short> Photon.Realtime.AsyncOperationHandler.CompletionSource => _result

The completion source to trigger by operation callbacks.

◆ Token

CancellationToken Photon.Realtime.AsyncOperationHandler.Token => _cancellation == null ? CancellationToken.None : _cancellation.Token

The cancellation token for the operation timeout, will return CancellationToken.None if no timeout is set.

◆ IsCancellationRequested

bool Photon.Realtime.AsyncOperationHandler.IsCancellationRequested => _cancellation == null ? false : _cancellation.IsCancellationRequested

Returns if cancellation has been requested.

Property Documentation

◆ Disposables

ConcurrentQueue<IDisposable> Photon.Realtime.AsyncOperationHandler.Disposables
get

A collection of additional objects or callbacks that need to be disposed once the operation handler is done. For example subscriptions to RealtimeClient.CallbackMessage.

◆ Name

string Photon.Realtime.AsyncOperationHandler.Name
getset

The name of the operation handler, only set in DEBUG build configuration.