August 2017
Intermediate to advanced
438 pages
14h 19m
English
The boost::mutex class takes care of all the synchronization stuff. When a thread tries to lock it via the boost::lock_guard<boost::mutex> variable and there is no other thread holding a lock, it successfully acquires unique access to the section of code until the lock is unlocked or destroyed. If some other thread already holds a lock, the thread that tried to acquire the lock waits until another thread unlocks the lock. All the locking/unlocking operations imply specific instructions so that the changes made in a critical section are visible to all threads. Also, you no longer need to:
Read now
Unlock full access