Public Types | Public Member Functions | Private Member Functions
Poco::Mutex Class Reference

#include <Mutex.h>

Inheritance diagram for Poco::Mutex:
Inheritance graph
[legend]

List of all members.

Public Types

typedef Poco::ScopedLock< MutexScopedLock

Public Member Functions

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

Private Member Functions

 Mutex (const Mutex &)
Mutexoperator= (const Mutex &)

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


Member Typedef Documentation

Definition at line 69 of file Mutex.h.


Constructor & Destructor Documentation

Definition at line 50 of file Mutex.cpp.

creates the Mutex.

Definition at line 55 of file Mutex.cpp.

Poco::Mutex::Mutex ( const Mutex ) [private]

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


Member Function Documentation

void Poco::Mutex::lock ( ) [inline]

destroys the Mutex.

Definition at line 172 of file Mutex.h.

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

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

Definition at line 178 of file Mutex.h.

Mutex& Poco::Mutex::operator= ( const Mutex ) [private]
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 185 of file Mutex.h.

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

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


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


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Sat Dec 28 2013 17:20:20