Boost logo

Boost :

Subject: [boost] [asio] timer cancelling
From: Mr. Robert G Palmer Jr. (robert.palmer_at_[hidden])
Date: 2011-03-21 09:26:20


boost 1.45.0
WinXP SP3

What is the difference between boost::deadline_timer.cancel() and the cancellation that happens due to boost::deadline_timer.expires_from_now()?

I'm doing an async_read_some() inside of a wrapper function I have written (based on http://lists.boost.org/Archives/boost/2007/04/120339.php). I have a read handler and a timer handler (I want the bytes read value and could probably combine the two handlers into one with the appropriate modification to the bind call). The read handler works, and then I cancel the timer, but the NEXT TIME I call the wrapper function, the timer hander fires with a boost::asio::error::operation_aborted. The timer object is local to the wrapper function, but the io_service is not, it is passed in, so it seems the io_service is holding onto the timer completion handler AND the fact that it was cancelled.

Is there a way to clean this out before exiting my wrapper function?

Is the 'expires_from_now()' calling the timer handler or is it the first call to run_one()?

Thanks,

-- 
Robert G. Palmer, Jr.
robert.palmer_at_[hidden]

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk