7 #include "wvtimestream.h" 9 WvTimeStream::WvTimeStream():
10 last(wvtime_zero), next(wvtime_zero), ms_per_tick(0)
19 ms_per_tick = msec > 0 ? msec : 0;
20 next = msecadd(now, ms_per_tick);
46 next = tvdiff(next, tvdiff(last, now));
56 diff = msecdiff(next, now);
57 diff = diff < 0 ? 0 : diff;
58 if (diff < si.msec_timeout || si.msec_timeout < 0)
59 si.msec_timeout = diff;
83 next = msecadd(next, ms_per_tick);
85 if (msecdiff(next, now) > ms_per_tick * 100 ||
86 msecdiff(now, next) > ms_per_tick * 100)
91 next = msecadd(last, ms_per_tick);
93 else if (msecdiff(next, now) > ms_per_tick * 10)
95 next = msecadd(now, ms_per_tick);
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
bool alarm_was_ticking
This will be true during callback execution if the callback was triggered by the alarm going off...
Based on (and interchangeable with) struct timeval.
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
void set_timer(time_t msec)
Every 'msec' milliseconds, select() will return true on this stream.
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
the data structure used by pre_select()/post_select() and internally by select(). ...
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
virtual bool isok() const
return true if the stream is actually usable right now
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.