I am using (single threaded) a boost::asio:io_service
to handle a lot of tcp connections. For each connection I use a deadline_timer to catch timeouts. If any of the connections times out, I can use none of the results of the other connections. Therefore I want to completely restart my io_service. I thought that calling io_service.stop()
would allow "finished" handlers in the queue to be called and would call handlers in the queue with an error.
However it looks like the handlers remain in the queue and therefore calling io_service.reset()
and later io_service.run()
brings the old handlers back up.
Can anyone confirm that the handlers indeed remain in the queue even after io_service.stop()
is called. And if so, what are the possibilities to completly reset the io_service, e.g. remove all queued handlers?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…