Threads Module User's Guide : PART II Concurrency Packages : Chapter 4 The Synchronization Package
Chapter 4 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.
Interpackage Dependencies
The Synchronization package depends on the Execution Tracing and Thread-compatible Exception packages of the Threads Module.
Including the Header Files
The rw\sync directory contains a header file for each class in the Synchronization package. It is named classname.h. You can also access the declarations for the entire package through sync.h, an umbrella file that includes the header files for all the classes.