You must protect access to std::queue
. If you are using boost protect it using boost::mutex
. Now if you have multiple readers and one writer thread look at boost::shared_lock
(for readers) and boost::unique_lock
(for writer).
However if you will encounter writer thread starvation look at boost::shared_mutex
.