AnimatLab  2
Test
StdUtils::CStdCriticalSectionInternal Class Reference

Standard critical section. More...

#include <StdCriticalSectionInternal.h>

+ Inheritance diagram for StdUtils::CStdCriticalSectionInternal:
+ Collaboration diagram for StdUtils::CStdCriticalSectionInternal:

Classes

class  InternalLocker
 Internal locker. More...
 

Public Member Functions

 CStdCriticalSectionInternal ()
 Default constructor. More...
 
 ~CStdCriticalSectionInternal ()
 Destructor. More...
 
bool Enter (long lMilliTimeout=-1)
 Try's to enter the critical section. Waits until it can get in, or until timeout. More...
 
bool Leave ()
 Leaves this critical section. More...
 
bool TryEnter ()
 Gets the try enter. More...
 
- Public Member Functions inherited from StdUtils::CStdCriticalSection
 CStdCriticalSection ()
 Default constructor. More...
 
 ~CStdCriticalSection ()
 Destructor. More...
 

Protected Attributes

bool m_bOwned
 
boost::thread::id m_dwOwner
 
std::atomic< int > m_iBusy
 Tells if this critical section is currently being used.
 
ULONG m_ulRefCnt
 The number of reference counts to this critical section.
 

Friends

class InternalLocker
 

Detailed Description

Standard critical section.

This is a critical section class used to lock a section of code. This is primarily used when multithreading to prevent multiple threads from modifying the same resources.

Author
dcofer
Date
5/3/2011

Definition at line 50 of file StdCriticalSectionInternal.h.

Constructor & Destructor Documentation

StdUtils::CStdCriticalSectionInternal::CStdCriticalSectionInternal ( )

Default constructor.

Author
dcofer
Date
5/3/2011

Definition at line 98 of file StdCriticalSectionInternal.cpp.

StdUtils::CStdCriticalSectionInternal::~CStdCriticalSectionInternal ( )

Destructor.

This releases the critical section lock if one was gained with a TryEnter call

Author
dcofer
Date
5/3/2011

Definition at line 114 of file StdCriticalSectionInternal.cpp.

References Leave().

+ Here is the call graph for this function:

Member Function Documentation

bool StdUtils::CStdCriticalSectionInternal::Enter ( long  lMilliTimeout = -1)

Try's to enter the critical section. Waits until it can get in, or until timeout.

Author
dcofer
Date
5/3/2011
Parameters
lMilliTimeoutThe milli timeout.
Returns
true if it succeeds, false if it fails.

Definition at line 172 of file StdCriticalSectionInternal.cpp.

References TryEnter().

+ Here is the call graph for this function:

bool StdUtils::CStdCriticalSectionInternal::Leave ( )
virtual

Leaves this critical section.

This unlocks the critical section for the current thread if the current thread already owns the critical section and it only has one "lock" on the critical section. If the lock count (the number of times the same thread has it locked) is greater than one, then the count is simply decremented.

Author
dcofer
Date
5/3/2011
Returns
true if it succeeds, false if it fails.

Implements StdUtils::CStdCriticalSection.

Definition at line 213 of file StdCriticalSectionInternal.cpp.

References m_iBusy, and m_ulRefCnt.

Referenced by ~CStdCriticalSectionInternal().

+ Here is the caller graph for this function:

bool StdUtils::CStdCriticalSectionInternal::TryEnter ( )
virtual

Gets the try enter.

This locks the critical section for the current thread if no other thread already owns the critical section. If the current thread already owns the critical section and this is reentry, the current thread is allowed to pass

Author
dcofer
Date
5/3/2011
Returns
true if it succeeds, false if it fails.

Implements StdUtils::CStdCriticalSection.

Definition at line 135 of file StdCriticalSectionInternal.cpp.

References m_iBusy, and m_ulRefCnt.

Referenced by Enter().

+ Here is the caller graph for this function:


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