RWNullMutexLock RWSynchObject
LockGuard ReadLockGuard ReadUnlockGuard |
TryLockGuard TryReadLockGuard TryWriteLockGuard |
UnlockGuard WriteLockGuard WriteUnlockGuard |
acquire() acquireRead() |
acquireWrite() isAcquired() |
release() tryAcquire() |
tryAcquireRead() tryAcquireWrite() |
#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 a 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 }
typedef RWTLockGuard<RWNullMutexLock> LockGuard; typedef RWTReadLockGuard<RWNullMutexLock> ReadLockGuard; typedef RWTWriteLockGuard<RWNullMutexLock> WriteLockGuard; typedef RWTTryLockGuard<RWNullMutexLock> TryLockGuard; typedef RWTTryReadLockGuard<RWNullMutexLock> TryReadLockGuard; typedef RWTTryWriteLockGuard<RWNullMutexLock> TryWriteLockGuard; typedef RWTUnlockGuard<RWNullMutexLock> UnlockGuard; typedef RWTReadUnlockGuard<RWNullMutexLock> ReadUnlockGuard; typedef RWTWriteUnlockGuard<RWNullMutexLock> WriteUnlockGuard;
Predefined types for compatible guards.
RWNullMutexLock(RWStaticCtor);
Creates an RWNullMutexLock.
RWMutexLock(RWCancellationState
state=RW_CANCELLATION_DISABLED);
Creates an RWNullMutexLock. state is ignored.
void acquire(void);
Does nothing
RWWaitStatus acquire(unsigned long milliseconds);
Returns RW_THR_ACQUIRED.
void acquireRead(void);
Does nothing.
RWWaitStatus acquireRead(unsigned long milliseconds);
Returns RW_THR_ACQUIRED.
void acquireWrite(void);
Does nothing.
RWWaitStatus acquireWrite(unsigned long milliseconds);
Returns RW_THR_ACQUIRED.
RWBoolean isAcquired(void) const;
Returns TRUE.
NOTE: Only available from the debug version of the library
void release(void);
Does nothing.
RWBoolean tryAcquire(void);
Returns TRUE.
RWBoolean tryAcquireRead(void);
Returns TRUE.
RWBoolean tryAcquireWrite(void);
Returns TRUE.
RWMutexLock, RWTLockGuard<Resource>, RWTUnlockGuard<Resource>, RWTTryLockGuard<Resource>
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.