+ MutexLock l(mutex);
+ while(1)
+ {
+ if(slots.empty())
+ {
+ if(block)
+ sem.wait();
+ else
+ return;
+ }
+
+ next = slots.begin()->slot;
+ const TimeStamp &stamp = next->get_timeout();
+ const TimeStamp t = now();
+ if(stamp<=t)
+ break;
+ else if(block)
+ sem.wait(stamp-t);
+ else
+ return;
+ }
+
+ pop_heap(slots.begin(), slots.end());
+ slots.pop_back();