6 // blocks enq() and deq() when queue is FULL or EMPTY
10 fifo(size_t limit=0) : max_(limit) {}
12 bool enq(T e, bool blocking=true) {
14 while (max_ && q_.size() >= max_) {
17 has_space_c_.wait(ml);
20 non_empty_c_.notify_one();
27 non_empty_c_.wait(ml);
30 if (max_ && q_.size() < max_)
31 has_space_c_.notify_one();
42 cond non_empty_c_; // q went non-empty
43 cond has_space_c_; // q is not longer overfull
44 size_t max_; // maximum capacity of the queue, block enq threads if exceeds this limit