On Fri, Oct 9, 2015 at 9:43 AM, Vladimir Prus
In particular, suppose I have this:
// Thread 1
boost::promise<int> pi; boost::future<int> fi = pi.get_future();
// pass pi to thread 2 somehow
fi.then(....);
// Thread 2
pi.set_value(100);
And I want continuation to be executed in thread 1, assuming that thread 1 runs Qt event loop, allowing me to use QTimer::singleShot, or queued signal, or similar mechanism. How would I go about making boost::future do it? Has anybody done so?
Thanks, Volodya
I might have misunderstood the question but I would assume a solution would
be to build boost.thread with executors enabled[1]. And then wrap the QT
event loop in an executor interface[2] and use the
boost::future<T>::then(Executor&, ...) overload.
I haven't really use this stuff, I have been playing with it in order to
find out how to combine boost::asio::io_service and boost::future/async, to
no avail sadly.
/M
[1] it is guarded by a macro which I cannot find in the docs:
BOOST_THREAD_PROVIDES_EXECUTORS
[2]
http://www.boost.org/doc/libs/1_59_0/doc/html/thread/synchronization.html#th...
[3] the doc specify an overload then(Scheduler& S) but the code looks like
this:
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
template