10 #define SHARED_QUEUE_H
15 #include <condition_variable>
46 :maxCapacity(capacity)
59 bool result = (queue.empty());
68 size_t result = queue.size();
78 queue.push_back(value);
80 notEmpty.notify_one();
102 template <
typename T>
105 std::unique_lock<std::mutex> l(lock);
107 notFull.wait(l, [
this](){
return queue.size() < maxCapacity; });
108 queue.push_back(value);
110 notEmpty.notify_one();
114 template <
typename T>
117 std::unique_lock<std::mutex> l(lock);
119 notEmpty.wait(l, [
this](){
return queue.size() > 0; });
121 item = queue.front();
124 notFull.notify_one();
127 template <
typename T>
133 std::cout << c <<
" ";
135 std::cout << std::endl;