
18 May
2013
18 May
'13
5:54 p.m.
Is there a way to ask the io_service to distribute a particular handler to every thread that is running the service? My use case is per-thread watchdogs, and I need the worker threads to ping the watchdog on some regular interval (e.g., every 5 seconds).
No, io_service threads are expected to be used for scalability purposes only, and the application logic is expected to be "decoupled" from the threading. What you can do instead is to use multiple io_service's, instead of multiple threads running 1 io_service (see io_service-per-CPU example).