January 2018
Intermediate to advanced
374 pages
9h 53m
English
Here, we are going to show an example of a lock-free queue, which is a relatively simple but useful lock-free data structure. Lock-free queues can be used for one-way communication with threads that cannot use locks to synchronize access to shared data.
Its implementation is straightforward because of the limited requirements: it only supports one reader thread and one writer thread. The capacity of the queue is also fixed and cannot change during runtime.
The writer thread is allowed to call:
The reader thread is allowed to call:
Both threads can call: