From 2df873a435ff139cf9d1b10b666d75e6dc6da442 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 16 Feb 2012 10:05:01 +0900 Subject: Timers identified by dynamically generated handles Timers are not longer identified by hard-wired IDs. Signed-off-by: Martin Sustrik --- src/monitor.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/monitor.cpp') 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)); } -- cgit v1.2.3