Boost logo

Boost :

Subject: Re: [boost] Executor associated to the future continuations (was [thread] boost::future::then)
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2015-10-29 16:00:31


Le 29/10/15 14:09, Vicente J. Botet Escriba a écrit :
> Le 29/10/15 11:13, Vladimir Prus a écrit :
>> On 29-Oct-15 12:49 PM, Vicente J. Botet Escriba wrote:
>>> Le 29/10/15 10:08, Vladimir Prus a écrit :
>>>> On 11-Oct-15 9:30 PM, Vicente J. Botet Escriba wrote:
>>>>> Le 10/10/15 16:58, Vicente J. Botet Escriba a écrit :
>>>>>> Le 10/10/15 15:26, Vicente J. Botet Escriba a écrit :
>>>>>>> Le 10/10/15 07:57, Vladimir Prus a écrit :
>>>>>>>>
>>>> Vicente,
>>>>
>>>> I've created a very early experiment, here:
>>>>
>>>> https://gist.github.com/vprus/3a7bea25e4c0a0e4222d
>>>>
>>>> Does it look generally right for you?
>>> I don't know Qt. It seems ok beside tht fact that you create an
>>> Executor for each Task. Maybe this is not important for
>>> you as your Executor class is adapting Qt.
>>
>> It's not hugely important, since in practice the work performance is
>> orders of magnitude longer
>> than QObject creation. Anyway, I possibly can create an executor per
>> thread on demand, and reuse them.
> Don't worry with the new version where you will give the Executor at
> promise creation the cost will be minimal in your case.
>>
Hrr, I'm not able to remove completely the Executor type erasure as the
type of f2 would depend on the Executor associated to the shared state
of f1, that is unknown.

     MyExecutor ex;
     auto f1 = async(ex, cont);
     auto f2 = f1.then(launch::inherit, cont);

So, f1 could have a shared_state that depends on MyExecutor, however f2
would have an shared state that depends on the type erased boost::executor.

That means that it is better for the user to store the specific executor
in some way and use it as follow

     auto f2 = f1.then(ex, cont);

Anyway, I would try implement as at least I will able to optimize

     auto f1 = async(ex, cont);

and

     promise<int> p(ex);

Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk