From: Guilherme Maciel Ferreira Date: Fri, 15 Apr 2011 13:44:51 +0000 (+0200) Subject: Removed one level of indirection provided by PingScheduler::handle_next_ping X-Git-Tag: v1.0~74 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=166fd9e914f3105ed2a03b8a7bac307b364a3faf;p=pingcheck Removed one level of indirection provided by PingScheduler::handle_next_ping --- diff --git a/src/host/pingscheduler.cpp b/src/host/pingscheduler.cpp index aa0c302..5a05c34 100644 --- a/src/host/pingscheduler.cpp +++ b/src/host/pingscheduler.cpp @@ -74,19 +74,6 @@ bool PingScheduler::resolve_ping_address() return true; } -void PingScheduler::setup_ping() -{ - BOOST_ASSERT( 1 <= IpList.get_resolved_ip_count() ); - - string destination_ip = IpList.get_next_ip(); - bool ping_success = ping( destination_ip ); - - update_ping_statistics( ping_success ); - update_ping_elapsed_time(); - - schedule_next_ping(); -} - bool PingScheduler::ping( const string &destination_ip ) const { BOOST_ASSERT( !destination_ip.empty() ); @@ -102,17 +89,25 @@ bool PingScheduler::ping( const string &destination_ip ) const return pinger.ping( destination_ip ); } -void PingScheduler::schedule_next_ping() +void PingScheduler::setup_next_ping() { - BOOST_ASSERT( 0 < PingIntervalInSec ); + BOOST_ASSERT( 1 <= IpList.get_resolved_ip_count() ); - (void) NextPingTimer.expires_from_now( seconds( PingIntervalInSec ) ); - NextPingTimer.async_wait( bind( &PingScheduler::handle_next_ping, this ) ); + string destination_ip = IpList.get_next_ip(); + bool ping_success = ping( destination_ip ); + + update_ping_statistics( ping_success ); + update_ping_elapsed_time(); + + schedule_next_ping(); } -void PingScheduler::handle_next_ping() +void PingScheduler::schedule_next_ping() { - setup_ping(); + BOOST_ASSERT( 0 < PingIntervalInSec ); + + (void) NextPingTimer.expires_from_now( seconds( PingIntervalInSec ) ); + NextPingTimer.async_wait( bind( &PingScheduler::setup_next_ping, this ) ); } void PingScheduler::update_ping_statistics( const bool ping_success ) diff --git a/src/host/pingscheduler.h b/src/host/pingscheduler.h index 209fad1..88d7603 100644 --- a/src/host/pingscheduler.h +++ b/src/host/pingscheduler.h @@ -38,10 +38,9 @@ public: private: bool resolve_ping_address(); - void setup_ping(); bool ping( const std::string &destination_ip ) const; + void setup_next_ping(); void schedule_next_ping(); - void handle_next_ping(); void update_ping_statistics( const bool ping_success ); void update_ping_interval(); void update_ping_elapsed_time();