Photon Server API

Public Member Functions | Static Public Member Functions | List of all members
ExitGames.Threading.ReadLock Struct Reference

This IDisposable uses the ReaderWriterLockSlim for critical sections that allow one writer and multiple reader. The counter parts are WriteLock and UpgradeableReadLock. It is used to replaces try-finally blocks with "using" statements. More...

Inheritance diagram for ExitGames.Threading.ReadLock:

Public Member Functions

void Dispose ()
 Calls ReaderWriterLockSlim.ExitReadLock. More...
 

Static Public Member Functions

static IDisposable Enter (ReaderWriterLockSlim syncObject)
 Enters a critical section with ReaderWriterLockSlim.EnterReadLock and returns a new instance of ReadLock. More...
 
static IDisposable TryEnter (ReaderWriterLockSlim syncObject, int millisecondsTimeout)
 Enters a critical section with ReaderWriterLockSlim.TryEnterReadLock(int) and returns a new instance of ReadLock. More...
 

Detailed Description

This IDisposable uses the ReaderWriterLockSlim for critical sections that allow one writer and multiple reader. The counter parts are WriteLock and UpgradeableReadLock. It is used to replaces try-finally blocks with "using" statements.

using (ReadLock.Enter(rwLock))
{
// critical section here
}

Member Function Documentation

◆ Dispose()

void ExitGames.Threading.ReadLock.Dispose ( )
inline

Calls ReaderWriterLockSlim.ExitReadLock.

◆ Enter()

static IDisposable ExitGames.Threading.ReadLock.Enter ( ReaderWriterLockSlim  syncObject)
inlinestatic

Enters a critical section with ReaderWriterLockSlim.EnterReadLock and returns a new instance of ReadLock.

Parameters
syncObjectThe reader writer lock.
Returns
A ReadLock that can be disposed to call ReaderWriterLockSlim.ExitReadLock.

◆ TryEnter()

static IDisposable ExitGames.Threading.ReadLock.TryEnter ( ReaderWriterLockSlim  syncObject,
int  millisecondsTimeout 
)
inlinestatic

Enters a critical section with ReaderWriterLockSlim.TryEnterReadLock(int) and returns a new instance of ReadLock.

Parameters
syncObjectThe reader writer lock.
millisecondsTimeoutThe timeout for ReaderWriterLockSlim.TryEnterReadLock(int) in milliseconds.
Returns
A WriteLock that can be disposed to call ReaderWriterLockSlim.ExitReadLock.
Exceptions
LockTimeoutExceptionReaderWriterLockSlim.TryEnterReadLock(int) returned false.