GaSectionLock
class is used for automatic access control with help of GaCriticalSection class. Synchronization object can be automatically acquired when instance of GaSectionLock
is created. If synchronization object is locked by instance of GaSectionLock
it is released when the instance goes out of scope. This mechanism provides simple way of managing critical sections because users don't have to worry about releasing of synchronization object in most cases, but for more complicated cases LOCK
and UNLOCK
macros can be used with instances of this class or with GaCriticalSection class. GaSectionLock
is mainly employed by LOCK_OBJECT
and LOCK_THIS_OBJECT
.
More...
#include <D:/Temp/vs/gal/source/Threading.h>
Public Member Functions | |
GaSectionLock (GaCriticalSection *section, bool aquireLock) | |
Constructor associates new instance of this class with underlying synchronization object. | |
~GaSectionLock () | |
Destructor releases underlying synchronization object if it was acquired by this instance of GaSectionLock class. | |
void GACALL | Lock () |
Lock method locks underlying synchronization object. If it was already locked by this instance of GaSectionLock class, call has no effect. Details of locking synchronization object are described in specification of GaCriticalSection::Lock method. | |
void GACALL | Unlock () |
Unlock method unlocks underlying synchronization object. If it wasn't locked by this instance of GaSectionLock class, call has no effect. Details of unlocking synchronization object are described in specification of GaCriticalSection::Unlock method. | |
Private Attributes | |
GaCriticalSection * | _section |
Pointer to underlying synchronization object which is managed by this lock. | |
bool | _locked |
Keeps track whether underlying synchronization object is locked by this instance of GaSectionLock class. |
GaSectionLock
class is used for automatic access control with help of GaCriticalSection class. Synchronization object can be automatically acquired when instance of GaSectionLock
is created. If synchronization object is locked by instance of GaSectionLock
it is released when the instance goes out of scope. This mechanism provides simple way of managing critical sections because users don't have to worry about releasing of synchronization object in most cases, but for more complicated cases LOCK
and UNLOCK
macros can be used with instances of this class or with GaCriticalSection class. GaSectionLock
is mainly employed by LOCK_OBJECT
and LOCK_THIS_OBJECT
.
Object of this class shouldn't be used from multiple threads simultaneously.
Threading::GaSectionLock::GaSectionLock | ( | GaCriticalSection * | section, | |
bool | aquireLock | |||
) | [inline] |
Constructor associates new instance of this class with underlying synchronization object.
section | pointer to underlying synchronization object. | |
aquireLock | if this parameter is set to true constructor tries to acquire underlying object immediately. |
Threading::GaSectionLock::~GaSectionLock | ( | ) | [inline] |
Destructor releases underlying synchronization object if it was acquired by this instance of GaSectionLock
class.
void GACALL Threading::GaSectionLock::Lock | ( | ) | [inline] |
Lock
method locks underlying synchronization object. If it was already locked by this instance of GaSectionLock
class, call has no effect. Details of locking synchronization object are described in specification of GaCriticalSection::Lock
method.
void GACALL Threading::GaSectionLock::Unlock | ( | ) | [inline] |
Unlock method unlocks underlying synchronization object. If it wasn't locked by this instance of GaSectionLock
class, call has no effect. Details of unlocking synchronization object are described in specification of GaCriticalSection::Unlock
method.
Pointer to underlying synchronization object which is managed by this lock.
bool Threading::GaSectionLock::_locked [private] |
Keeps track whether underlying synchronization object is locked by this instance of GaSectionLock
class.