Library: Foundation
Package: Threading
Header: Poco/Mutex.h
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.
Direct Base Classes: MutexImpl
All Base Classes: MutexImpl
Member Functions: lock, tryLock, unlock
typedef Poco::ScopedLock < Mutex > ScopedLock;
Mutex();
creates the Mutex.
~Mutex();
destroys the Mutex.
void lock();
Locks the mutex. Blocks if the mutex is held by another thread.
bool tryLock();
Tries to lock the mutex. Returns false immediately if the mutex is already held by another thread. Returns true if the mutex was successfully locked.
void unlock();
Unlocks the mutex so that it can be acquired by other threads.