Boost logo

Boost Users :

Subject: Re: [Boost-users] Asio timer - how to restart it?
From: Igor R (boost.lists_at_[hidden])
Date: 2008-10-23 13:45:34


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

http://www.boost.org/doc/libs/1_36_0/doc/html/boost_asio/reference/basic_deadline_timer/async_wait.html

"For each call to async_wait(), the supplied handler will be called
exactly once. The handler will be called when:
  * The timer has expired.
  * The timer was cancelled, in which case the handler is passed the
error code boost::asio::error::operation_aborted."

So usually you test it like this:
void handler(const boost::system::error_code &err)
{
  if (err != boost::asio::error::operation_aborted)
  {
    // do what you want
  }

  //or:
  if (err && err != boost::asio::error::operation_aborted)
  {
    //...
  }
}


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