Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Poco::Mutex Class Reference

#include <Mutex.h>

+ Inheritance diagram for Poco::Mutex:
+ Collaboration diagram for Poco::Mutex:

Public Types

using ScopedLock = Poco::ScopedLock<Mutex>
 

Public Member Functions

 Mutex ()
 
 ~Mutex ()
 creates the Mutex.
 
void lock ()
 destroys the Mutex.
 
void lock (long milliseconds)
 
bool tryLock ()
 
bool tryLock (long milliseconds)
 
void unlock ()
 

Private Member Functions

 Mutex (const Mutex &)
 
Mutexoperator= (const Mutex &)
 
- Private Member Functions inherited from Poco::MutexImpl
 MutexImpl ()
 
 ~MutexImpl ()
 
void lockImpl ()
 
bool tryLockImpl ()
 
bool tryLockImpl (long milliseconds)
 
void unlockImpl ()
 

Detailed Description

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 53 of file Mutex.h.

Member Typedef Documentation

◆ ScopedLock

Definition at line 64 of file Mutex.h.

Constructor & Destructor Documentation

◆ Mutex() [1/2]

Poco::Mutex::Mutex ( )

◆ ~Mutex()

Poco::Mutex::~Mutex ( )

creates the Mutex.

◆ Mutex() [2/2]

Poco::Mutex::Mutex ( const Mutex & )
private

Unlocks the mutex so that it can be acquired by other threads.

Member Function Documentation

◆ lock() [1/2]

void Poco::Mutex::lock ( )
inline

destroys the Mutex.

Definition at line 273 of file Mutex.h.

+ Here is the call graph for this function:

◆ lock() [2/2]

void Poco::Mutex::lock ( long milliseconds)
inline

Locks the mutex. Blocks if the mutex is held by another thread.

Definition at line 279 of file Mutex.h.

+ Here is the call graph for this function:

◆ operator=()

Mutex & Poco::Mutex::operator= ( const Mutex & )
private

◆ tryLock() [1/2]

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.

Definition at line 286 of file Mutex.h.

+ Here is the call graph for this function:

◆ tryLock() [2/2]

bool Poco::Mutex::tryLock ( long milliseconds)
inline

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.

Definition at line 292 of file Mutex.h.

+ Here is the call graph for this function:

◆ unlock()

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.

Definition at line 298 of file Mutex.h.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: