6 #include <condition_variable>
15 #include <condition_variable>
26 typedef std::shared_ptr<std::barrier<>> BarrierPtr;
31 condition_variable m_cond;
37 lock_guard<mutex> lk(rhs.m_mut);
38 m_queue = rhs.m_queue;
41 lock_guard<mutex> lk(m_mut);
42 m_queue.push(move(data));
45 void pushNoMove(T data) {
46 lock_guard<mutex> lk(m_mut);
51 void waitAndPop(T &res)
53 unique_lock<mutex> lk(m_mut);
54 m_cond.wait(lk, [
this] {
return !m_queue.empty(); });
55 res = move(m_queue.front());
59 unique_lock<mutex> lk(m_mut);
60 m_cond.wait(lk, [
this] {
return !m_queue.empty(); });
61 move(m_queue.front());
65 lock_guard<mutex> lk(m_mut);
66 auto sz = m_queue.size();
70 lock_guard<mutex> lk(m_mut);
71 auto sz = m_queue.empty();
76 lock_guard<mutex> lk(m_mut);
77 auto fr = m_queue.front();
83 void operator=(
const std::queue<T> &D) {
86 void waitAndPopNoMOve(T &res)
88 unique_lock<mutex> lk(m_mut);
89 m_cond.wait(lk, [
this] {
return !m_queue.empty(); });
94 lock_guard<mutex> lk(m_mut);
97 res = move(m_queue.front());
103 shared_ptr<T> waitAndPop() {
104 unique_lock<mutex> lk(m_mut);
105 m_cond.wait(lk, [
this] {
return !m_queue.empty(); });
106 shared_ptr<T> res(make_shared<T>(move(m_queue.front())));
111 shared_ptr<T> tryPop() {
112 lock_guard<mutex> lk(m_mut);
115 shared_ptr<T> res(make_shared<T>(move(m_queue.front())));
121 typedef std::shared_ptr<SafeQueue<int>> SafeQueuePtr;
Definition: SafeQueue.hpp:28