Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] deadline_timer callback is not called
From: Daniele Barzotti (daniele.barzotti_at_[hidden])
Date: 2009-10-14 12:24:25


Igor R ha scritto:
> How could cause this kind of behavior?
>
> Another guess: do you call the timer functions (expires_from_now(),
> async_wait() ) from the thread that is running io_service or from
> another one? That is, who calls ProcessRTPPacket() function? If it's
> called from another thread, can you try the following:

No, from another one.
The thread that run the io_service simply runs it:

void io_worker_thread(void)
{
  io_service.run();
  std::cout << ">>> io_service.run() TERMINATED! <<<<<" << endl;
};

ProcessRTPPacket() is a library "event" and maybe it is called from
another thread!

Mmmm...so maybe, in the other project, it worked because I called timers
into the asio::serial_port::async_read_some callback that should be
inside the io_service thread! Isn't it?

> // instead of calling expires_from_now(), async_wait() directly...
> yourTimer_.get_io_service().post(boost::bind(&WaveStream::setTimer, this));
> //...
>
> void setTimer()
> {
> // Some debug message, to see if the function is called.
> ...expires_from_now(...);
> ...async_wait(...);
> }
>
> Now see if setTimer is called.

Yes, the setTimer is called, but the timer callback not!

Cheers,
Daniele.


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