SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Efficient stand-in for a mutual exclusion lock when synchroniztion is either unnecessary or not important. More...
#include <rw/sync/RWNullMutexLock.h>
An RWNullMutexLock is an efficient stand-in for a mutual exclusion lock, particularly when you know that critical sections of code do not need synchronization. For example, you may know that it is not possible for more than one thread to simultaneously enter a section of code that would otherwise require locking. In such cases, you can use an RWNullMutexLock to eliminate the unnecessary overhead of acquiring and releasing a mutex. This class can also be used to instantiate a single-threaded or non-thread-safe version of the template classes that accept a mutex parameter, such as RWTMonitor<Mutex> .
#include <rw/sync/RWMutexLock.h> #include <rw/sync/RWNullMutexLock.h> #if SYNCHRONIZATION_REQUIRED typedef RWMutexLock MUTEX; #else typedef RWNullMutexLock MUTEX; #endif MUTEX mutex; mutex.acquire(); // No cost if synchronization not required // critical section mutex.release(); // Same thing, this time using a guard: { MUTEX::Lockguard lock(mutex); // does nothing if // synchronization not required // critical section // If synchronization required, lock will be released // automatically }
Predefined type for compatible guard.
Predefined type for compatible guard.
Predefined type for compatible guard.
Predefined type for compatible guard.
Predefined type for compatible guard.
Predefined type for compatible guard.
Predefined type for compatible guard.
Predefined type for compatible guard.
Predefined type for compatible guard.
RWNullMutexLock::RWNullMutexLock | ( | RWStaticCtor | ) | [inline] |
Constructs a static instance, but does no direct initialization. The RWNullMutexLock is initialized on first use.
This constructor must be used only for static instances. Use of this constructor with an automatically or dynamically allocated instance produces errors or other unpredictable behavior.
Static instances are zero initialized, which results in an RWNullMutexLock with a cancellation state of RW_CANCELLATION_DISABLED.
RWNullMutexLock::RWNullMutexLock | ( | RWCancellationState | state = 0 |
) | [inline] |
Creates an RWNullMutexLock. The parameter state is currently ignored.
RWNullMutexLock::~RWNullMutexLock | ( | ) | [inline] |
Destructor.
RWNullMutexLock::RWNullMutexLock | ( | const RWNullMutexLock & | second | ) | [private] |
Copy construction prohibited.
RWWaitStatus RWNullMutexLock::acquire | ( | unsigned long | milliseconds | ) | [inline] |
Returns RW_THR_ACQUIRED.
void RWNullMutexLock::acquire | ( | void | ) | [inline] |
Does nothing.
RWWaitStatus RWNullMutexLock::acquireRead | ( | unsigned long | milliseconds | ) | [inline] |
Returns RW_THR_ACQUIRED.
void RWNullMutexLock::acquireRead | ( | ) | [inline] |
Does nothing.
RWWaitStatus RWNullMutexLock::acquireWrite | ( | unsigned long | milliseconds | ) | [inline] |
Returns RW_THR_ACQUIRED.
void RWNullMutexLock::acquireWrite | ( | ) | [inline] |
Does nothing.
bool RWNullMutexLock::isAcquired | ( | ) | const |
Returns true
.
RWNullMutexLock& RWNullMutexLock::operator= | ( | const RWNullMutexLock & | second | ) | [private] |
Assignment prohibited.
void RWNullMutexLock::release | ( | void | ) | [inline] |
Does nothing.
bool RWNullMutexLock::tryAcquire | ( | ) | [inline] |
Returns true
.
bool RWNullMutexLock::tryAcquireRead | ( | ) | [inline] |
Returns true
.
bool RWNullMutexLock::tryAcquireWrite | ( | ) | [inline] |
Returns true
.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.