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.