Hi, i have little problem with boost::asio library. My app receive and process data asynchronously, it create threads and run io_service.run() on each of them.
boost::asio::io_service io;
boost::thread_group thread_pool;
...
int cpu_cnt = get_cpu_count();
for (int i = 0; i < cpu_cnt; ++i)
{
thread_pool.create_thread( boost::bind(&run_service, &io) );
}
void run_service(boost::asio::io_service* io)
{
try
{
io->run();//make fun
}
catch(const std::exception& e)
{ //process error
}
catch(...)
{ //process error
}
}
Time after time, my application receives message(across windows messaging system) from some supervisor application that checks is my program alive or not. If my application wont reply, it will be restarted. The tricky part here is to check, that threads is running and not deadlocked. I can post handler to io_service like this:
io.post( &reply_to_supervisor );
but this method affects only one thread. How can i check that all threads is running and not deadlocked?