The Synchronization Package
Introducing the Synchronization Package
The principle role of the Synchronization package is to allow you to synchronize threads on a variety of operating systems and platforms. Thread synchronization protects the integrity of shared data and efficiently communicates changes in program state between cooperating threads.
The Synchronization package includes:
*Standard thread synchronization mechanisms
Synchronization mechanisms are encapsulated as C++ classes to ease multithread development. The standard mechanisms include a simple mutex, FIFO mutex, recursive mutex, semaphore, readers-writer lock, condition variable, and barrier.
*Exception-safe synchronization
To make locking safe in the presence of exceptions, the Threads Module has a family of guard classes that automatically acquire or release the various synchronization mechanisms. The lock, read-lock, and write-lock guard classes automatically acquire a synchronization resource when constructed and release that same resource when destructed. Similarly, the unlock, read-unlock, and write-unlock guard classes automatically release and reacquire a resource. The try-lock, try-read-lock, and try-write-lock guard classes acquire a resource, but only if available, and release that resource, but only if acquired.