#include <Mutex.h>
Public Types | |
typedef Poco::ScopedLock< Mutex > | ScopedLock |
Public Member Functions | |
void | lock (long milliseconds) |
void | lock () |
destroys the Mutex. | |
Mutex () | |
bool | tryLock (long milliseconds) |
bool | tryLock () |
void | unlock () |
~Mutex () | |
creates the Mutex. | |
Private Member Functions | |
Mutex (const Mutex &) | |
Mutex & | operator= (const Mutex &) |
A Mutex (mutual exclusion) is a synchronization mechanism used to control access to a shared resource in a concurrent (multithreaded) scenario. Mutexes are recursive, that is, the same mutex can be locked multiple times by the same thread (but, of course, not by other threads). Using the ScopedLock class is the preferred way to automatically lock and unlock a mutex.
Definition at line 58 of file Mutex.h.
typedef Poco::ScopedLock<Mutex> Poco::Mutex::ScopedLock |
Poco::Mutex::Mutex | ( | const Mutex & | ) | [private] |
Unlocks the mutex so that it can be acquired by other threads.
void Poco::Mutex::lock | ( | long | milliseconds | ) | [inline] |
bool Poco::Mutex::tryLock | ( | long | milliseconds | ) | [inline] |
bool Poco::Mutex::tryLock | ( | ) | [inline] |
Locks the mutex. Blocks up to the given number of milliseconds if the mutex is held by another thread. Throws a TimeoutException if the mutex can not be locked within the given timeout.
Performance Note: On most platforms (including Windows), this member function is implemented using a loop calling (the equivalent of) tryLock() and Thread::sleep(). On POSIX platforms that support pthread_mutex_timedlock(), this is used.
void Poco::Mutex::unlock | ( | ) | [inline] |
Locks the mutex. Blocks up to the given number of milliseconds if the mutex is held by another thread. Returns true if the mutex was successfully locked.
Performance Note: On most platforms (including Windows), this member function is implemented using a loop calling (the equivalent of) tryLock() and Thread::sleep(). On POSIX platforms that support pthread_mutex_timedlock(), this is used.