Primitives useful for multithreaded applications, for example, atomic counters, condition variables, and locks. More...
Classes | |
class | mi::base::Atom32 |
A 32-bit unsigned counter with atomic arithmetic, increments, and decrements. More... | |
class | mi::base::Condition |
Conditions allow threads to signal an event and to wait for such a signal, respectively. More... | |
class | mi::base::Lock |
Non-recursive lock class. More... | |
class | mi::base::Lock::Block |
Utility class to acquire a lock that is released by the destructor. More... | |
class | mi::base::Recursive_lock |
Recursive lock class. More... | |
class | mi::base::Recursive_lock::Block |
Utility class to acquire a lock that is released by the destructor. More... | |
Primitives useful for multithreaded applications, for example, atomic counters, condition variables, and locks.
|
inline |
The default constructor initializes the counter to zero.
mi::base::Atom32::Atom32 | ( | const Atom32 & | other | ) |
The copy constructor assigns the value of other
to the counter.
|
inline |
This constructor initializes the counter to value
.
|
explicit |
Constructor.
lock | If not NULL , this lock is acquired. If NULL , set() can be used to explicitly acquire a lock later. |
|
explicit |
Constructor.
lock | If not NULL , this lock is acquired. If NULL , set() can be used to explicitly acquire a lock later. |
|
inline |
Constructor.
mi::base::Lock::Lock | ( | ) |
Constructor.
|
protected |
Locks the lock.
|
protected |
Locks the lock.
|
inline |
Conversion operator to mi::Uint32.
Uint32 mi::base::Atom32::operator++ | ( | ) |
Increments the counter by one (pre-increment).
Uint32 mi::base::Atom32::operator++ | ( | int | ) |
Increments the counter by one (post-increment).
Uint32 mi::base::Atom32::operator-- | ( | ) |
Decrements the counter by one (pre-decrement).
Uint32 mi::base::Atom32::operator-- | ( | int | ) |
Decrements the counter by one (post-decrement).
mi::base::Recursive_lock::Recursive_lock | ( | ) |
Constructor.
void mi::base::Lock::Block::release | ( | ) |
Releases the lock.
Useful to release the lock before the destructor is called.
void mi::base::Recursive_lock::Block::release | ( | ) |
Releases the lock.
Useful to release the lock before the destructor is called.
|
inline |
void mi::base::Lock::Block::set | ( | Lock * | lock | ) |
Acquires a lock.
Releases the current lock (if it is set) and acquires the given lock. Useful to acquire a different lock, or to acquire a lock if no lock was acquired in the constructor.
This method does nothing if the passed lock is already acquired by this class.
lock | The new lock to acquire. |
void mi::base::Recursive_lock::Block::set | ( | Recursive_lock * | lock | ) |
Acquires a lock.
Releases the current lock (if it is set) and acquires the given lock. Useful to acquire a different lock, or to acquire a lock if no lock was acquired in the constructor.
This method does nothing if the passed lock is already acquired by this class.
lock | The new lock to acquire. |
|
inline |
Assigns rhs
to the counter and returns the old value of counter.
|
inline |
Waits for the condition to be signaled until a given timeout.
If the condition is already signaled at this time the call will return immediately.
timeout | Maximum time period (in seconds) to wait for the condition to be signaled. |
true
if the timeout was hit, and false
if the condition was signaled.
|
protected |
Tries to lock the lock.
|
protected |
Tries to lock the lock.
bool mi::base::Lock::Block::try_set | ( | Lock * | lock | ) |
Tries to acquire a lock.
Releases the current lock (if it is set) and tries to acquire the given lock. Useful to acquire a different lock without blocking, or to acquire a lock without blocking if no lock was acquired in the constructor.
This method does nothing if the passed lock is already acquired by this class.
lock | The new lock to acquire. |
true
if the lock was acquired, false
otherwise. bool mi::base::Recursive_lock::Block::try_set | ( | Recursive_lock * | lock | ) |
Tries to acquire a lock.
Releases the current lock (if it is set) and tries to acquire the given lock. Useful to acquire a different lock without blocking, or to acquire a lock without blocking if no lock was acquired in the constructor.
This method does nothing if the passed lock is already acquired by this class.
lock | The new lock to acquire. |
true
if the lock was acquired, false
otherwise.
|
protected |
Unlocks the lock.
|
protected |
Unlocks the lock.
|
inline |
Waits for the condition to be signaled.
If the condition is already signaled at this time the call will return immediately.
mi::base::Lock::Block::~Block | ( | ) |
Destructor.
Releases the lock (if it is acquired).
mi::base::Recursive_lock::Block::~Block | ( | ) |
Destructor.
Releases the lock (if it is acquired).
|
inline |
Destructor.
mi::base::Lock::~Lock | ( | ) |
Destructor.
mi::base::Recursive_lock::~Recursive_lock | ( | ) |
Destructor.