7#ifndef VIEWSHED_NOTIFYQUEUE_H_INCLUDED
8#define VIEWSHED_NOTIFYQUEUE_H_INCLUDED
12#include <condition_variable>
39 std::lock_guard<std::mutex> lock(m_mutex);
40 m_queue.push(std::move(t));
51 std::unique_lock<std::mutex> lock(m_mutex);
53 [
this] {
return !m_queue.empty() || m_done || m_stop; });
60 t = std::move(m_queue.front());
73 std::lock_guard<std::mutex> lock(m_mutex);
83 std::lock_guard<std::mutex> lock(m_mutex);
94 std::lock_guard<std::mutex> lock(m_mutex);
103 std::lock_guard<std::mutex> lock(m_mutex);
111 std::lock_guard<std::mutex> lock(m_mutex);
112 return m_queue.size();
116 std::queue<T> m_queue{};
117 mutable std::mutex m_mutex{};
118 std::condition_variable m_cv{};
This is a thread-safe queue.
Definition: notifyqueue.h:26
bool isStopped()
Determine if the queue was stopped.
Definition: notifyqueue.h:101
size_t size() const
Get the current size of the queue.
Definition: notifyqueue.h:109
void stop()
Unblock all readers regardless of queue state.
Definition: notifyqueue.h:80
~NotifyQueue()
Destructor.
Definition: notifyqueue.h:29
void done()
When we're done putting things in the queue, set the end condition.
Definition: notifyqueue.h:70
void push(T &&t)
Push an object on the queue and notify readers.
Definition: notifyqueue.h:36
bool pop(T &t)
Get an item from the queue.
Definition: notifyqueue.h:49
bool isDone()
Determine if the queue was emptied completely.
Definition: notifyqueue.h:92
Core portability definitions for CPL.