7 // blocks enq() and deq() when queue is FULL or EMPTY
11 fifo(size_t limit=0) : max_(limit) {}
12 bool enq(T, bool blocking=true);
22 cond non_empty_c_; // q went non-empty
23 cond has_space_c_; // q is not longer overfull
24 size_t max_; // maximum capacity of the queue, block enq threads if exceeds this limit
27 template<class T> bool
28 fifo<T>::enq(T e, bool blocking)
31 while (max_ && q_.size() >= max_) {
34 has_space_c_.wait(ml);
37 non_empty_c_.notify_one();
41 template<class T> void
46 non_empty_c_.wait(ml);
49 if (max_ && q_.size() < max_)
50 has_space_c_.notify_one();