6 // blocks enq() and deq() when queue is FULL or EMPTY
10 fifo(size_t limit=0) : max_(limit) {}
11 bool enq(T, bool blocking=true);
21 cond non_empty_c_; // q went non-empty
22 cond has_space_c_; // q is not longer overfull
23 size_t max_; // maximum capacity of the queue, block enq threads if exceeds this limit
26 template<class T> bool
27 fifo<T>::enq(T e, bool blocking)
30 while (max_ && q_.size() >= max_) {
33 has_space_c_.wait(ml);
36 non_empty_c_.notify_one();
40 template<class T> void
45 non_empty_c_.wait(ml);
48 if (max_ && q_.size() < max_)
49 has_space_c_.notify_one();