Boost logo

Boost :

Subject: Re: [boost] [thread] boost::future::then
From: Vladimir Prus (vladimir.prus_at_[hidden])
Date: 2015-10-09 09:44:00

On 09-Oct-15 4:02 PM, Mikael Olenfalk wrote:
> On Fri, Oct 9, 2015 at 9:43 AM, Vladimir Prus <vladimir.prus_at_[hidden]>
> wrote:
>> 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?
> 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.


thanks for the response. I suppose it would work - although if I need to pass this
executor any time I call 'then', it become rather awkward rather quickly. It would
be nicer if promise could have an executor, and pass it to future and then
to futures returned by 'then', so that I only need to to specify custom behaviour
when creating a promise - that can be easily wrapped in a function.

Do you have any comments on presence or absence of bugs, and overall API maturity?
Having to define macros to get useful functionality is not quite perfect.


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