How to properly terminate the child thread, which is waiting for the operation?

The pseudo code of the child thread that waits for data and sends message to the main thread to obtain this data, as it correctly terminate if the main thread received a message on completion? Feel the lack of knowledge and maybe something to read? Do use boost::asio and I want cross-platform support.
while(true)
{
some_monitor.async_monotor(callback_handler);
io_service.run();
io_service.reset();
 }


If I understand correctly, the io_service.run() — then I wait until the system notifies my thread and I have no other ways to complete this but himself(the child thread) to send the data to signal completion?
void callback_handler(data d)
{
 if (d == STOP)
{
 running = false;
}
}
...
while(running)
{
some_monitor.async_monotor(callback_handler);
io_service.run();
io_service.reset();
 }


Blagodaru in advance.
October 3rd 19 at 02:35
1 answer
October 3rd 19 at 02:37
Solution
I don't remember exactly, but try to call io_service.stop() from another thread to interrupt the execution of run().
Thank you again! Day, everything works under windows and under linux. - joe.Crist commented on October 3rd 19 at 02:40

Find more questions by tags BoostC++multithreading