Boost logo

Boost Users :

Subject: [Boost-users] Monitoring thread liveness using multiple threads with a single asio io_service
From: Krajnak, Mike (GE Healthcare) (michael.krajnak_at_[hidden])
Date: 2011-04-11 14:33:47

We have a server implemented with boost::asio that uses a vector of
threads with a single io_service as in the asio http server 3 sample


We want to check on the liveness of threads by having each thread
periodically call back to a thread manager so that we can confirm it is
still running.


To do that we have an inner loop that uses run_one() so we can call our
heartbeat function after each action is completed (pseudo code):




      num_ops = io_svc.run_one(ec)



  while (num_ops > 0);


However, asio makes no garantees on how work is dispatched to threads.
In our testing work seems to go prefentially to one thread for several
iterations before going to another thread with no pattern that we can


Is there some way we can change this solution so that we can be
reasonably sure each thread will be called at least once in a some
period of time or some other mechanism for monitoring thread liveness?









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