CARMA C++
carma::util::ScopedPthreadMutexLock Class Reference

A scope class (i.e. More...

#include <carma/util/ScopedPthreadMutexLock.h>

Public Member Functions

 ScopedPthreadMutexLock (PthreadMutex &mutex)
 Obtains a lock on the given mutex for the caller's thread (possibly waiting an indeterminate amount of time along the way). More...
 
 ~ScopedPthreadMutexLock ()
 Releases the lock on the mutex (that was given to the constructor) held by the caller's thread. More...
 

Detailed Description

A scope class (i.e.

a class that does or manages something for the lifetime of the instance) that makes simple PthreadMutex lock management easier in a C++ world.

If your locking needs are not so simple then ScopedPthreadMutexLockManager might be what you need. Usage might look something like this:

* static long long gSharedValue;
* static PthreadMutex gSharedValueGuard;
*
* void
* UpdateSharedValue( const long long newValue ) {
* ScopedPthreadMutexLock scopeLock( gSharedValueGuard );
*
* gSharedValue = newValue;
* }
*

Definition at line 31 of file ScopedPthreadMutexLock.h.

Constructor & Destructor Documentation

carma::util::ScopedPthreadMutexLock::ScopedPthreadMutexLock ( PthreadMutex mutex)
explicit

Obtains a lock on the given mutex for the caller's thread (possibly waiting an indeterminate amount of time along the way).

Parameters
mutexThe mutex to to wait for a lock on

Definition at line 64 of file ScopedPthreadMutexLock.h.

carma::util::ScopedPthreadMutexLock::~ScopedPthreadMutexLock ( )

Releases the lock on the mutex (that was given to the constructor) held by the caller's thread.

Definition at line 72 of file ScopedPthreadMutexLock.h.


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