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/monitor.cpp | |
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/monitor.cpp')
-rw-r--r-- | src/monitor.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/monitor.cpp b/src/monitor.cpp index 7665005..b29c874 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -26,7 +26,8 @@ xs::monitor_t::monitor_t (xs::io_thread_t *io_thread_) : own_t (io_thread_, options_t ()), - io_object_t (io_thread_) + io_object_t (io_thread_), + timer (NULL) { } @@ -54,19 +55,20 @@ void xs::monitor_t::log (int sid_, const char *text_) void xs::monitor_t::process_plug () { // Schedule sending of the first snapshot. - add_timer (500 + (generate_random () % 1000), timer_id); + timer = add_timer (500 + (generate_random () % 1000)); } void xs::monitor_t::process_stop () { - rm_timer (timer_id); + rm_timer (timer); + timer = NULL; send_done (); delete this; } -void xs::monitor_t::timer_event (int id_) +void xs::monitor_t::timer_event (handle_t handle_) { - xs_assert (id_ == timer_id); + xs_assert (handle_ == timer); // Send the snapshot here! sync.lock (); @@ -74,5 +76,5 @@ void xs::monitor_t::timer_event (int id_) sync.unlock (); // Wait before sending next snapshot. - add_timer (500 + (generate_random () % 1000), timer_id); + timer = add_timer (500 + (generate_random () % 1000)); } |