Boost logo

Boost Users :

Subject: Re: [Boost-users] Asio timer - how to restart it?
From: Peleg (pelegsh_at_[hidden])
Date: 2008-10-23 12:42:17


Igor R wrote:
>
>> boost::asio::deadline_timer timer(io,
>> boost::posix_time::seconds(5));
>> boost::thread thread(boost::bind(&boost::asio::io_service::run,
>> &io));
>> timer.async_wait(on_time_out);
>> delay(3);
>
> Note that you set the timer timeout to be 5 second, but wait 3 second
> only.
>
>> cout << second_clock::local_time() << " Restarting timer" << endl;
>> timer.expires_from_now(boost::posix_time::seconds(5));
>
> You just change the timeout here. To restart the timer you have to
> call timer.async_wait().
> By the way, note that the timer is not threadsafe so I'm not sure it's
> legal to restart it here or to change its timeout this way.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>

Thanks, that's it, now how do I filter only successful timer triggers?
I added the following line to on_time_out():

cout << "Error #" << error << ": " << error.message() << endl;
 
And successful call resulted the following output:
Error #system:0: The operation completed successfully

but I failed to find the correct error_code value I've tried:

if(error == boost::asio::error::success)
and
if(error == boost::system::error::success)

but non of them is valid, what is the valid success condition?
thanks again,
Peleg

-- 
View this message in context: http://www.nabble.com/Asio-timer---how-to-restart-it--tp20128401p20134911.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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