From 4e91c69af52b29242e6b586be0411ae1840b1e15 Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Mon, 2 May 2011 14:39:54 +0200 Subject: [PATCH] Starts pinging immediately, instead of schedule to start "interval" seconds later --- src/host/pingscheduler.cpp | 14 +++++++++++++- src/host/pingscheduler.h | 1 + 2 files changed, 14 insertions(+), 1 deletions(-) diff --git a/src/host/pingscheduler.cpp b/src/host/pingscheduler.cpp index 8b5bd55..b04f534 100644 --- a/src/host/pingscheduler.cpp +++ b/src/host/pingscheduler.cpp @@ -49,6 +49,9 @@ PingScheduler::~PingScheduler() { } +/** + * @brief Starts the pinging thread and returns immediately. + */ bool PingScheduler::start_pinging_thread() { Thread = thread( &PingScheduler::start_pinging, this ); @@ -56,6 +59,9 @@ bool PingScheduler::start_pinging_thread() return true; } +/** + * @brief Waits for the pinging thread to finish. + */ void PingScheduler::wait_pinging_thread() { BOOST_ASSERT( Thread.joinable() ); @@ -71,13 +77,19 @@ bool PingScheduler::start_pinging() return false; } - schedule_next_ping(); + setup_next_ping(); + // event processing loop, it is a blocking call! IoService.run(); return true; } +void PingScheduler::stop_pinging() +{ + IoService.stop(); +} + bool PingScheduler::resolve_ping_address() { bool address_resolved = IpList.resolve(); diff --git a/src/host/pingscheduler.h b/src/host/pingscheduler.h index 4042ef9..c01cf23 100644 --- a/src/host/pingscheduler.h +++ b/src/host/pingscheduler.h @@ -37,6 +37,7 @@ public: bool start_pinging_thread(); void wait_pinging_thread(); bool start_pinging(); + void stop_pinging(); private: bool resolve_ping_address(); -- 1.7.1