Boost logo

Boost Users :

Subject: Re: [Boost-users] Asio timer - how to restart it?
From: Bill Somerville (bill_at_[hidden])
Date: 2008-10-23 11:45:49

Bill Somerville wrote:
> Peleg wrote:
>> Hello,
>> I'm writing an Asio based serial port communication application.
>> I've tried to use Asio timer as receive time out timer.
>> The implementation consist of restarting the timer each time the receive
>> event is called, , so it'll trigger only after time out duration with
>> no receive event.
>> The problem is that when I try to restart the timer, using
>> expires_from_now(), the timer immediately triggers.
> You are not getting asynchronous timeouts, all you are seeing is the
> first timer being cancelled when you queue the second.
> All asio async actions happen in the context of the io_service, you
> need to call somewhere.
> You have either oversimplified your example or you need to re-read the
> asio examples.
Sorry, ignore my response - I didn't look at your code closely enough!

Igor R is correct, you have prematurely cancelled your first timer.
> Bill Somerville
> ...
>> How do I restart to timer in the right way?
>> Thanks,
>> Peleg
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
Bill Somerville

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at