Threading::GaSectionLock Class Reference

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>

List of all members.

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.


Detailed Description

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.


Constructor & Destructor Documentation

Threading::GaSectionLock::GaSectionLock ( GaCriticalSection section,
bool  aquireLock 
) [inline]

Constructor associates new instance of this class with underlying synchronization object.

Parameters:
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.


Member Function Documentation

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.


Member Data Documentation

Pointer to underlying synchronization object which is managed by this lock.

Keeps track whether underlying synchronization object is locked by this instance of GaSectionLock class.


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

Genetic Algorithm Library
Coolsoft Software Development