VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Attributes | Private Member Functions
DtScopedLock Class Reference

DtScopedLock provides a Boost source compatible scoped lock for DtMutex. More...

+ Collaboration diagram for DtScopedLock:

Public Member Functions

 DtScopedLock (DtMutex &mx, bool initially_locked=true)
 Constructs a DtScopedLock on a mutex and conditionally locks that mutex.
 ~DtScopedLock ()
 Destructor, which will unlock if the mutex was locked.
void lock ()
 Lock the mutex.
void unlock ()
 Unlock the mutex.
bool locked () const
 operator const void * () const
 else null pointer.

Protected Attributes

DtMutexmyMutex
bool myLockedState

Private Member Functions

 DtScopedLock (const DtScopedLock &)
 Ensures non-copiable.
DtScopedLockoperator= (const DtScopedLock &)

Detailed Description

DtScopedLock provides a Boost source compatible scoped lock for DtMutex.

A DtScopedLock is a safe locking pattern for use in multi-threaded applications. DtScopedLock is non-copiable object, which should be created on the stack. The lock ensures that upon deallocation the lock is released.

DtMutex io_mutex;

void threadSafe_printf(const char* string)
{
DtScopedLock lock(io_mutex);
printf(string);
}

Constructor & Destructor Documentation

DtScopedLock::DtScopedLock ( DtMutex mx,
bool  initially_locked = true 
)
explicit

Constructs a DtScopedLock on a mutex and conditionally locks that mutex.

DtScopedLock::~DtScopedLock ( )

Destructor, which will unlock if the mutex was locked.

DtScopedLock::DtScopedLock ( const DtScopedLock )
private

Ensures non-copiable.

Member Function Documentation

void DtScopedLock::lock ( )

Lock the mutex.

bool DtScopedLock::locked ( ) const
Returns
The locked state of the mutex.
Return values
trueThe mutex is locked.
falseThe mutex is unlocked.
DtScopedLock::operator const void * ( ) const

else null pointer.

DtScopedLock& DtScopedLock::operator= ( const DtScopedLock )
private
void DtScopedLock::unlock ( )

Unlock the mutex.

Member Data Documentation

bool DtScopedLock::myLockedState
protected
DtMutex& DtScopedLock::myMutex
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Fri May 15 06:36:13 EDT 2015 from SVN revision 153263
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)