Mutexes


Detailed Description

Mutexes (short for Mutual Exclusion) are sincronization objects shared among different threads used to synchronize their acces to common resources.

A mutex can be locked by a thread to prevent other threads to lock it; if a mutex is locked a second time, the thread that tries to lock it must wait for the previous locker to unlock it. If a given mutex is always used in conjuntion with a given set of data, then a thread can lock a mutex to be sure that, when it is able to proceed after the lock() statement, the data is untouchable until the lock is released.

Mutex can be used also to exclude mutual access to functions or processes. I.e., a program may want to write data on a log file, then a mutex can be used to prevent concurrent access to the file handle (data lock) but also to prevent any other thread from calling functions that are going to write log entries (functional lock).

In Object Oriented Programming, a class may have a mutex as member and methods that access the class data concurrently may lock it to allow only being executed only by one thread at a time.

A special kind of mutexes are the so called read-write mutexes. Those objects allow two different kind of locking: read only locking and write locking. The principle is that, if many threads are reading a set of data that is not going to change it is useless to lock it; only when a thread wants to alter that set of data is necessary to prevent other threads from mangling with data at the same moment.


Classes

class  Wefts::Mutex
 Implements a very fast, non reentrant mutex. More...

class  Wefts::RMutex
 This is a reentrant mutex with spinlock. More...

class  Wefts::RRWMutex
 This is an advanced (and fully reentrant) read/write mutex. More...

class  Wefts::RWMutex
 This is a read/write mutex. More...

class  Wefts::XMutex
 Advanced mutex class. More...


Generated on Tue Oct 5 14:57:01 2004 for Wefts by doxygen 1.3.7