June 2017
Intermediate to advanced
532 pages
12h 59m
English
The term mutex stands for mutual exclusion. In order to prevent that concurrently running threads alter the same object in a non-orchestrated way that might lead to data corruption, we can use mutex objects. The STL provides different mutex classes with different specialties. They all have in common that they have a lock and an unlock method.
Whenever a thread is the first one to call lock() on a mutex that was not locked before, it owns the mutex. At this point, other threads will block on their lock calls, until the first thread calls unlock again. std::mutex can do exactly this.
There are many different mutex classes in the STL:
| Type name | Description |
| mutex |
Standard mutex with a lock and an unlock method. Provides ... |
Read now
Unlock full access