Boost logo

Boost :

Subject: Re: [boost] [thread] boost::future::then
From: Mikael Olenfalk (mikael.olenfalk_at_[hidden])
Date: 2015-10-09 09:02:42

On Fri, Oct 9, 2015 at 9:43 AM, Vladimir Prus <vladimir.prus_at_[hidden]>

> 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.


[1] it is guarded by a macro which I cannot find in the docs:


[3] the doc specify an overload then(Scheduler& S) but the code looks like

        template<typename Ex, typename F>
        inline BOOST_THREAD_FUTURE<typename
        then(Ex& ex, BOOST_THREAD_FWD_REF(F) func); // EXTENSION

Boost list run by bdawes at, gregod at, cpdaniel at, john at