-
- if (is_equal(absolute, next_event_))
- {
- next_event_ = find_next_event();
- }
- }
- else
- {
- invalidate();
- }
-}
-
-
-scalar timer::find_next_event()
-{
- scalar next_fire = std::numeric_limits<scalar>::max();
-
- hash<unsigned,timer*,hash_function>::iterator it;
- for (it = timers_.begin(); it.valid(); ++it)
- {
- scalar absolute = (*it).second->absolute_;
- if (absolute < next_fire) next_fire = absolute;
- }
-
- return next_fire;
-}
-
-
-scalar timer::seconds_remaining() const
-{
- return absolute_ - ticks();
-}
-
-scalar timer::next_expiration() const
-{
- return absolute_;
-}
-
-bool timer::is_expired() const
-{
- return seconds_remaining() < 0.0;
-}
-
-bool timer::is_repeating() const
-{
- return mode_ == repeat;
-}
-
-
-void timer::fire_expired_timers(scalar t)
-{
- if (t < next_event_) return;
-
- hash<unsigned,timer*,hash_function>::iterator it;
- for (it = timers_.begin(); it.valid(); ++it)
- {
- timer* timer = (*it).second;
- if (timer->is_expired()) timer->fire();
-
- if (it.end()) break;