Starts pinging immediately, instead of schedule to start "interval" seconds later
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@intra2net.com>
Mon, 2 May 2011 12:39:54 +0000 (14:39 +0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@intra2net.com>
Mon, 2 May 2011 12:39:54 +0000 (14:39 +0200)
src/host/pingscheduler.cpp
src/host/pingscheduler.h

index 8b5bd55..b04f534 100644 (file)
@@ -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();
index 4042ef9..c01cf23 100644 (file)
@@ -37,6 +37,7 @@ public:
     bool start_pinging_thread();
     void wait_pinging_thread();
     bool start_pinging();
+    void stop_pinging();
 
 private:
     bool resolve_ping_address();