5 #include <condition_variable>
28 std::lock_guard<std::mutex> lock(mutex);
35 std::unique_lock<std::mutex> lock(mutex);
43 std::unique_lock<std::mutex> lock(mutex);
44 while (queue.empty()) {
47 T val = queue.front();
60 std::unique_lock<std::mutex> lock(mutex);
70 mutable std::mutex mutex;
71 std::condition_variable cond;
Thread safe queue.
Definition: msgqueue.h:15
bool empty()
Return true if the queue is empty.
Definition: msgqueue.h:34
void push(T t)
Add object at the end of the queue.
Definition: msgqueue.h:27
T pop_blocking()
Wait until there is an object in the queue, then remove and return the first object.
Definition: msgqueue.h:42
bool fetch(T &val)
A non-blocking pop.
Definition: msgqueue.h:58