Photon Server API
Public Member Functions | Static Public Member Functions | List of all members
ExitGames.Threading.WriteLock Struct Reference

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

Inheritance diagram for ExitGames.Threading.WriteLock:

Public Member Functions

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

Static Public Member Functions

static IDisposable Enter (ReaderWriterLockSlim syncObject)
 Enters a critical section with ReaderWriterLockSlim.EnterWriteLock and returns a new instance of WriteLock. More...
 
static IDisposable TryEnter (ReaderWriterLockSlim syncObject, int millisecondsTimeout)
 Enters a critical section with ReaderWriterLockSlim.TryEnterWriteLock(int) and returns a new instance of WriteLock. More...
 

Detailed Description

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

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

Member Function Documentation

void ExitGames.Threading.WriteLock.Dispose ( )
inline

Calls ReaderWriterLockSlim.ExitWriteLock.

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

Enters a critical section with ReaderWriterLockSlim.EnterWriteLock and returns a new instance of WriteLock.

Parameters
syncObjectThe reader writer lock.
Returns
A WriteLock that can be disposed to call ReaderWriterLockSlim.ExitWriteLock.
static IDisposable ExitGames.Threading.WriteLock.TryEnter ( ReaderWriterLockSlim  syncObject,
int  millisecondsTimeout 
)
inlinestatic

Enters a critical section with ReaderWriterLockSlim.TryEnterWriteLock(int) and returns a new instance of WriteLock.

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