#include <LevelMutex.h>
Public Member Functions | |
MultiMutexLocker (LevelMutexInfo::MutexContainer &mutexes, bool lock=true) | |
MultiMutexLocker (LevelMutexInfo::MutexContainer &mutexes, unsigned int milliSeconds, bool lock=true) | |
~MultiMutexLocker (void) | |
Destructs the locker, and determines if it needs to unlock the mutexes. | |
bool | Lock (void) |
bool | Unlock (void) |
bool | IsLocked (void) const |
Returns true if the mutexes are locked by this object. | |
const LevelMutexInfo::MutexContainer & | GetMutexes (void) const |
Provides access to the collection of mutexes controlled by this. |
Loki::MultiMutexLocker::MultiMutexLocker | ( | LevelMutexInfo::MutexContainer & | mutexes, | |
bool | lock = true | |||
) | [explicit] |
Creates an object to lock and unlock a collection of mutexes for a function. This will throw if an attempt to lock any mutex fails. If an exception occurs, it unlocks mutexes it previously locked.
mutex | Reference to a collection of mutexes. | |
lock | True if function wants to lock the mutex as this gets constructed. |
References Loki::LevelMutexInfo::MultiLock().
Loki::MultiMutexLocker::MultiMutexLocker | ( | LevelMutexInfo::MutexContainer & | mutexes, | |
unsigned int | milliSeconds, | |||
bool | lock = true | |||
) |
Creates an object to lock and unlock a collection of mutexes for a function. This waits a specified amount of time for other threads to unlock each mutex that is locked. This will throw if an attempt to lock any mutex fails. If an exception occurs, it unlocks mutexes it previously locked.
mutexes | Reference to a collection of mutexes. | |
milliSeconds | Amount of time to wait for another thread to unlock the mutex. | |
lock | True if function wants to lock the mutexes as this gets constructed. |
References Loki::LevelMutexInfo::MultiLock().
bool Loki::MultiMutexLocker::Lock | ( | void | ) |
You can call this to lock (or relock) the mutexes. In theory, you can lock and unlock mutexes several times within a function in order to give other threads access to resources while this function does not need them.
References Loki::LevelMutexInfo::MultiLock().
bool Loki::MultiMutexLocker::Unlock | ( | void | ) |
You can call this to unlock the mutexes before the destructor does it. By unlocking the mutexes before returning, the function can do other operations without making other threads wait too long.
References Loki::LevelMutexInfo::MultiUnlock().