CriticalSection Class Reference

A critical section, a synchronization primitive that is typically more efficient than but roughly semantically equivalent to a Mutex. More...

#include <CriticalSection.h++>

Inheritance diagram for CriticalSection:

Inheritance graph
[legend]
Collaboration diagram for CriticalSection:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 CriticalSection () throw ()
 Constructor.
 ~CriticalSection () throw ()
 Destructor.
void enter () throw ()
 Enter the critical section, blocking if necessary.
void lock () throw ()
 Equivalent to enter().
bool tryEnter () throw ()
 Try to enter the critical section, returning immediately if it could not be entered.
void leave () throw ()
 Leave the critical section.
void unlock () throw ()
 Equivalent to leave().


Detailed Description

A critical section, a synchronization primitive that is typically more efficient than but roughly semantically equivalent to a Mutex.

Only one thread may be "within" a critical section at any one time.

Critical sections are recursive, so a thread may re-enter a critical section that it has already entered. However, the thread must leave the critical section the same number of times that it has entered it in order to release it.

Author:
Mark Lindner

Constructor & Destructor Documentation

CriticalSection (  )  throw ()

Constructor.

~CriticalSection (  )  throw ()

Destructor.

It is the calling code's responsibility to ensure that a CriticalSection is deleted only when no thread is within it.


Member Function Documentation

void enter (  )  throw ()

Enter the critical section, blocking if necessary.

void leave (  )  throw ()

Leave the critical section.

void lock (  )  throw () [inline, virtual]

Equivalent to enter().

Implements Lock.

bool tryEnter (  )  throw ()

Try to enter the critical section, returning immediately if it could not be entered.

Returns:
true if the critical section was entered, false otherwise.

void unlock (  )  throw () [inline, virtual]

Equivalent to leave().

Implements Lock.


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

Generated on Sat Apr 17 23:03:08 2010 for libcommonc++ by  doxygen 1.5.9