Scenario:
– My main (UI) thread (Thread “M”) runs, and spins up a worker thread (“W”) to control with some hardware.
– “W” wants to send progress notifications to “M” every so often.
– The notification-invocation can’t block “W”… “W” needs to make the call and return immediately; “M” will process the notification async and not return anything to “W”.
– “M” must notified by a callback running on thread “M”.
– Must be able to pass data (don’t worry about thread-safeness of data).
.NET has just such a facility in it’s System.ComponentModel.AsyncOperation class, but I’m wanting to create cross-platform code, not just .NET or even strictly Win32 (though my 1st platform is native c++ on Win32).
Using Boost would be a plus.
I’ve read this:
Boost: Fire and forget asynchronous function call?
but am wondering if there’s a simpler want than to spin up additional helper threads.
Any ideas and/or links would be greatly appreciated!
-Dave
If you are using Boost.Thread then you can use a condition variable.