Proud::CriticalSectionLock Class Reference

The object that 'lock accesses' CriticalSection object. More...

Public Member Functions

 CriticalSectionLock (CriticalSection &cs, bool initialLock)
 
 CriticalSectionLock ()
 
void SetCriticalSection (CriticalSection &cs, bool initialLock)
 
CriticalSectionGetCriticalSection () const
 
bool IsLocked () const
 
 ~CriticalSectionLock ()
 
void Lock ()
 
bool TryLock ()
 
void UnsafeLock ()
 
void Unlock ()
 
int GetRecursionCount ()
 

Detailed Description

The object that 'lock accesses' CriticalSection object.

  • Usually created and used as a local variable.
  • When this object is destroyed, it automatically unlocks the critical section that was locked by this.
// Example
void foo()
{
CriticalSectionLock lock(critSec, true);
...
// automatically unlocked here.
}

Constructor & Destructor Documentation

Proud::CriticalSectionLock::CriticalSectionLock ( CriticalSection cs,
bool  initialLock 
)
inline

It is possible to directly lock the critical section object at constructor.

Parameters
csThe critical section object to use
initialLockIf it is true then the constructor immediately locks it.
Proud::CriticalSectionLock::CriticalSectionLock ( )
inline

This is constructor that using set critical section later.

Proud::CriticalSectionLock::~CriticalSectionLock ( )
inline

Destructor

  • If there is a Critical Section occupied by this object then it automatically relieves.

Member Function Documentation

int Proud::CriticalSectionLock::GetRecursionCount ( )
inline

Inquire the time that the lock is over

bool Proud::CriticalSectionLock::IsLocked ( ) const
inline

Is it locked?

void Proud::CriticalSectionLock::Lock ( )
inline

This occupies the critical section.

bool Proud::CriticalSectionLock::TryLock ( )
inline

Perform Try Lock.

Returns
Same value as CriticalSection.TryLock()
void Proud::CriticalSectionLock::Unlock ( )
inline

This relieves occupied critical section.