Reputation: 307
I am reading multicast input using async_receive_from
. So the idea is that when I detect a gap, I will notify another helper thread to request/get the gap filling messages. While this is in the works the main thread will continue to receive and queue any incoming messages. This part I can implement. The other thread can use waitforsingleobject and I can pass it the details through shared memory and notify an event to wake it up.
But once it completes it task, how do I get the helper thread to interrupt the async_receive_from
in the initiating thread? And when it comes up out of the the read it knows who interrupted so it will then know what to do next?
Upvotes: 0
Views: 829
Reputation: 33655
Why are you using shared memory between threads?
That aside, the mechanism you should use for executing something in the context of the io_service
which is managing the socket is post()
. You can post any arbitrary event to the io_service, and it will execute in that context. Quite easy really... Because you are calling async_receive_from
, it's not blocking, i.e. the io_service can dispatch other events, which is why the post
will work.
Upvotes: 1