diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2012-02-16 10:05:01 +0900 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-02-16 10:05:01 +0900 |
commit | 2df873a435ff139cf9d1b10b666d75e6dc6da442 (patch) | |
tree | 042b0a349ca84919041fb37df7e5a3b7195d065d /src/poller_base.hpp | |
parent | b67f88a7d6322a293ac3e3be9d6df9f358509221 (diff) |
Timers identified by dynamically generated handles
Timers are not longer identified by hard-wired IDs.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/poller_base.hpp')
-rw-r--r-- | src/poller_base.hpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/poller_base.hpp b/src/poller_base.hpp index 15e03a6..5edb5d4 100644 --- a/src/poller_base.hpp +++ b/src/poller_base.hpp @@ -47,7 +47,7 @@ namespace xs virtual void out_event (fd_t fd_) = 0; // Called when timer expires. - virtual void timer_event (int id_) = 0; + virtual void timer_event (handle_t handle_) = 0; }; class poller_base_t @@ -73,12 +73,11 @@ namespace xs virtual void stop () = 0; // Add a timeout to expire in timeout_ milliseconds. After the - // expiration timer_event on sink_ object will be called with - // argument set to id_. - void add_timer (int timeout_, xs::i_poll_events *sink_, int id_); + // expiration timer_event on sink_ object will be called. + handle_t add_timer (int timeout_, xs::i_poll_events *sink_); - // Cancel the timer created by sink_ object with ID equal to id_. - void rm_timer (xs::i_poll_events *sink_, int id_); + // Cancel the timer identified by the handle. + void rm_timer (handle_t handle_); protected: @@ -100,7 +99,7 @@ namespace xs struct timer_info_t { xs::i_poll_events *sink; - int id; + std::multimap <uint64_t, timer_info_t>::iterator self; }; typedef std::multimap <uint64_t, timer_info_t> timers_t; timers_t timers; |