- set_mutex.lock();
- Timer *next=0;
- TimeStamp next_ts;
- for(set<Timer *>::iterator i=timers.begin(); i!=timers.end(); ++i)
- {
- const TimeStamp &ts=(*i)->get_timeout();
- if(ts<next_ts || !next)
- {
- next_ts=ts;
- next=*i;
- }
- }
- set_mutex.unlock();
-
- if(next)
- {
- const TimeStamp t=now();
- if(next_ts<=t || sem.wait(next_ts-t)==1)
- {
- if(next->signal_timeout.emit())
- next->timeout+=next->interval;
- else
- delete next;
- }
- }