|
Boost Users : |
Subject: [Boost-users] Inverval timer.
From: Alexei Sergeev (alexeisergeev_at_[hidden])
Date: 2009-02-12 08:58:56
Hello, I want some function / functor to run every n seconds, is there right
timer in boost for that? I tried to loop deadline_timer but wasn't able to get
it work more than one time.
Here is part of code I tryied:
//bool _isOnline; // status of internet connection.
//boost::asio::io_service _ioService; // need for boost timers.
//boost::asio::deadline_timer _internetConnectionTimer;
void Logic::InitializeInternetConnectionChecking( long secondsInterval )
{
_internetConnectionTimer.expires_from_now(
boost::posix_time::seconds( secondsInterval ) );
_internetConnectionTimer.async_wait(
boost::bind( &Logic::CheckInternetConnection, this ) );
_ioService.poll();
}
void Logic::InitializeInternetConnectionChecking()
{
InitializeInternetConnectionChecking( 5 );
}
void Logic::CheckInternetConnection()
{
if ( _isOnline = IsLanOrRasInetConnect() )
onOnline();
else
onOffline();
_ioService.reset();
InitializeInternetConnectionChecking();
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net