5 // blocks enq() and deq() when queue is FULL or EMPTY
12 #include "lang/verify.h"
19 bool enq(T, bool blocking=true);
26 std::condition_variable non_empty_c_; // q went non-empty
27 std::condition_variable has_space_c_; // q is not longer overfull
28 unsigned int max_; //maximum capacity of the queue, block enq threads if exceeds this limit
32 fifo<T>::fifo(int limit) : max_(limit)
36 template<class T> bool
43 template<class T> bool
44 fifo<T>::enq(T e, bool blocking)
48 if (!max_ || q_.size() < max_) {
53 has_space_c_.wait(ml);
58 non_empty_c_.notify_one();
62 template<class T> void
69 non_empty_c_.wait(ml);
73 if (max_ && q_.size() < max_) {
74 has_space_c_.notify_one();