Boost logo

Boost Users :

Subject: [Boost-users] Way to Promise the io_service.run() Is Running
From: Bo Zhou (bo.schwarzstein_at_[hidden])
Date: 2016-03-16 09:58:31


Hi !

I have a program which has a following logic

   1. Start the UDP listening in daemon thread
   2. Send the UDP command from main thread, and wait the response, maybe
   from the local

So the program itself might also receive the message from second step.

But the problem is, on Windows, the receiving thread will be executed
before the main thread starts to send message, so the behaviour is correct.

On Linux that's opposite, the main thread will be in deadlock because the
1st thread is not running and 2nd step it's trying to receive something
after sending the command.

My question, in the main thread of my application, what could I do to
detect the io_service is running ? I tried to call m_io_services.stopped()
seems the state is not correct, so I'd like to know how can I wait until
the event loop in 1st step is running ?

Thank you very much !



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net