October 2018
Beginner
794 pages
19h 23m
English
We understand how a mutex lock works normally: if a lock is already locked, then attempting to take the lock will cause that thread to block (wait upon) the unlock occurring. What if one wants a design which goes something like this: if the lock is locked, don't make me wait; I'll do some other work and retry? This semantic is often referred to as busy-waiting or non-blocking, and is provided by the trylock variant. As the name suggests, we try for the lock and if we get it, great; if not, it's okay—we do not force the thread to wait. The lock might be taken by any thread within the process (or even outside if it's a process-shared mutex) including the same thread—if it's marked as recursive. ...
Read now
Unlock full access