GNU CommonC++
Public Member Functions | Friends | List of all members
ost::MutexCounter Class Reference

The Mutex Counter is a counter variable which can safely be incremented or decremented by multiple threads. More...

#include <thread.h>

Inheritance diagram for ost::MutexCounter:
ost::Mutex

Public Member Functions

 MutexCounter (const char *id=NULL)
 Create and optionally name a mutex protected counter. More...
 
 MutexCounter (int initial, const char *id=NULL)
 Create and optionally name a mutex protected counter with an initial value. More...
 
- Public Member Functions inherited from ost::Mutex
 Mutex (const char *name=NULL)
 The mutex is always initialized as a recursive entity. More...
 
virtual ~Mutex ()
 Destroying the mutex removes any system resources associated with it. More...
 
void nameMutex (const char *name)
 Enable setting of mutex name for deadlock debug. More...
 
void enterMutex (void)
 Entering a Mutex locks the mutex for the current thread. More...
 
void enter (void)
 Future abi will use enter/leave/test members. More...
 
void leave (void)
 Future abi will use enter/leave/test members. More...
 
bool test (void)
 Future abi will use enter/leave/test members. More...
 
bool tryEnterMutex (void)
 Tries to lock the mutex for the current thread. More...
 
void leaveMutex (void)
 Leaving a mutex frees that mutex for use by another thread. More...
 

Friends

__EXPORT int operator++ (MutexCounter &mc)
 
__EXPORT int operator-- (MutexCounter &mc)
 

Additional Inherited Members

- Static Public Member Functions inherited from ost::Mutex
static void setDebug (bool mode)
 Enable or disable deadlock debugging. More...
 

Detailed Description

The Mutex Counter is a counter variable which can safely be incremented or decremented by multiple threads.

A Mutex is used to protect access to the counter variable (an integer). An initial value can be specified for the counter, and it can be manipulated with the ++ and – operators.

Author
David Sugar dyfet.nosp@m.@ost.nosp@m.el.co.nosp@m.m Thread protected integer counter.

Constructor & Destructor Documentation

◆ MutexCounter() [1/2]

ost::MutexCounter::MutexCounter ( const char *  id = NULL)

Create and optionally name a mutex protected counter.

Parameters
idname for mutex counter, optional for deadlock testing.

◆ MutexCounter() [2/2]

ost::MutexCounter::MutexCounter ( int  initial,
const char *  id = NULL 
)

Create and optionally name a mutex protected counter with an initial value.

Parameters
initialvalue of counter.
idname of counter, optional for deadlock testing.

Friends And Related Function Documentation

◆ operator++

__EXPORT int operator++ ( MutexCounter mc)
friend

◆ operator--

__EXPORT int operator-- ( MutexCounter mc)
friend

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