RWFIFOMutexLock RWSynchObject
LockGuard ReadLockGuard ReadUnlockGuard |
TryLockGuard TryReadLockGuard TryWriteLockGuard |
UnlockGuard WriteLockGuard WriteUnlockGuard |
acquire() acquireRead() |
acquireWrite() isAcquired() |
release() tryAcquire() |
tryAcquireRead() tryAcquireWrite() |
#include <rw/sync/RWFIFOMutexLock.h>
An RWFIFOMutexLock can be used to guarantee that blocking threads will acquire the mutex in the same order that they called the acquire() member function. On certain systems, thread attributes such as thread priority may be a factor in determining the order in which threads blocking on the same mutex will acquire that mutex when it is finally released. Class RWFIFOMutexLock eliminates those other factors and considers only the order of requests for acquisition.
#include <rw/sync/RWFIFOMutexLock.h> RWFIFOMutexLock fifomutex; fifomutex.acquire(); // critical section fifomutex.release(); // Same thing, this time using a guard: RWFIFOMutexLock fifomutex; { RWFIFOMutexLock::LockGuard lock(fifomutex); // critical section // Mutex will be released in RWFIFOMutexLock::LockGuard // destructor before leaving scope, especially important // if an exception is thrown! }
typedef RWTLockGuard<RWFIFOMutexLock> LockGuard; typedef RWTLockGuard<RWFIFOMutexLock> ReadLockGuard; typedef RWTLockGuard<RWFIFOMutexLock> WriteLockGuard; typedef RWTTryLockGuard<RWFIFOMutexLock> TryLockGuard; typedef RWTTryLockGuard<RWFIFOMutexLock> TryReadLockGuard; typedef RWTTryLockGuard<RWFIFOMutexLock> TryWriteLockGuard; typedef RWTUnlockGuard<RWFIFOMutexLock> UnlockGuard; typedef RWTUnlockGuard<RWFIFOMutexLock> ReadUnlockGuard; typedef RWTUnlockGuard<RWFIFOMutexLock> WriteUnlockGuard;
Predefined types for compatible guards.
RWFIFOMutexLock(RWCancellationState state=RW_CANCELLATION_DISABLED);
Creates and initializes an RWFIFOMutexLock. The thread cancellation state of the object is initialized to state.
~RWFIFOMutexLock();
Recovers any system resources used to implement the RWFIFOMutexLock.
void acquire(void);
Causes the current thread to block until the mutex is released, at which time the thread acquires the mutex and continues. If other threads are blocked waiting for this same mutex, the first thread that called this member function will acquire the mutex and continue. Possible exceptions include RWCancellation and RWTHRInternalError.
RWWaitStatus acquire(unsigned long milliseconds);
Blocks at least for the specified number of milliseconds, or until the mutex is released-whichever comes first. If the mutex is released within the specified time, acquires it, and continues. If the mutex is not released, returns RW_THR_TIMEOUT. Possible exceptions include RWCancellation and RWTHRInternalError.
void acquireRead(void);
Calls acquire(). Provided for compatibility with Read/Write locks. Possible exceptions include RWCancellation and RWTHRInternalError.
RWWaitStatus acquireRead(unsigned long milliseconds);
Calls acquire(milliseconds). Provided for compatibility with Read/Write locks. Possible exceptions include RWCancellation and RWTHRInternalError.
void acquireWrite(void);
Calls acquire(). Provided for compatibility with Read/Write locks. Possible exceptions include RWCancellation and RWTHRInternalError.
RWWaitStatus acquireWrite(unsigned long milliseconds);
Calls acquire(milliseconds). Provided for compatibility with Read/Write locks. Possible exceptions include RWCancellation and RWTHRInternalError.
RWBoolean isAcquired(void) const;
Determines whether the calling thread currently owns the mutex.
NOTE: Only available from the debug version of the library.
void release(void);
Releases the mutex, making it available. Possible exceptions include RWTHRInternalError.
RWBoolean tryAcquire(void);
Tries to acquire mutex without blocking. Returns TRUE if successful. Possible exceptions include RWCancellation and RWTHRInternalError.
RWBoolean tryAcquireRead(void);
Calls tryAcquire(). Provided for compatibility with Read/Write locks. Possible exceptions include RWCancellation and RWTHRInternalError.
RWBoolean tryAcquireWrite(void);
Calls tryAcquire(). Provided for compatibility with Read/Write locks. Possible exceptions include RWCancellation and RWTHRInternalError.
RWMutexLock, RWTRecursiveLock<Mutex>
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.