August 2017
Intermediate to advanced
438 pages
14h 19m
English
In the previous recipe, we saw how to safely access a common resource from different threads. But in that recipe, we were doing two system calls (in locking and unlocking mutex) to just get the value from an integer:
{ // Critical section begin. boost::lock_guard<boost::mutex> lock(i_mutex); i_snapshot = ++ shared_i; } // Critical section end.
This looks lame and slow! Can we make the code from the previous recipe better?
Read now
Unlock full access