Modern C++: Writing a thread-safe Queue

Marco Massenzio
6 min readJul 26, 2020

The STL provides a high-performance queue class in std::queue<T>; however, the API is not very intuitive, or easy, to use and it is not safe to access from multiple threads.
In this article, we will show how to wrap it in a more convenient, and thread-safe, API.

The C++ Standard Template Library (STL) offers a template-class std::queue<T> that implements Queue semantics: the usual push/ pop/…

--

--