Boost logo

Boost :

Subject: Re: [boost] [next gen future-promise] What to call the monadicreturn type?
From: Avi Kivity (avi_at_[hidden])
Date: 2015-05-25 16:45:26


On 05/25/2015 11:11 PM, Peter Dimov wrote:
> Avi Kivity wrote:
>> On 05/25/2015 09:04 PM, Peter Dimov wrote:
>> > Niall Douglas wrote:
>> >
>> >> I've got everything working except the sequence:
>> >>
>> >> promise<int> p;
>> >> p.set_value(5);
>> >> return p.get_future().get();
>> >>
>> >> This should reduce to a mov $5, %eax, but currently does not for
>> an >> unknown reason. I'm just about to go experiment and see why.
>> >
>> > I'm really struggling to see how all that could work. Where is the
>> > result stored? In the promise? Wouldn't this require the promise to
>> > outlive the future<>? This doesn't hold in general. How is it to be
>> > guaranteed?
>>
>> In seastar, we achieved this by reserving space for the result in
>> both future and promise, and by having future and promise track each
>> other (so they can survive moves).
>
> Doesn't this introduce a race between ~promise and ~future? ~future
> checks if( promise_ ), ~promise checks if( future_ ), and things get
> ugly.
>
> Fixing that requires synchronization, which makes mov $5, %eax
> impossible.
>

Ah, seastar futures are thread-unsafe. All computation is core-local,
with multiprocessing achieved by explicit message passing (using a local
future to represent the remote computation).


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