On Sat, Jun 1, 2013 at 8:35 PM, Vadim <[email protected]> wrote:

>
> On Sat, Jun 1, 2013 at 7:47 AM, Matthieu Monrocq <
> [email protected]> wrote:
>
>>
>>  1. Futures use a custom free-list allocator for performance.
>>>>
>>>
>> I don't see why Futures could not be allocated on the stack ?
>>
>> Since Rust is move aware and has value types, it seems to me this should
>> be possible.
>>
>
> Because I/O manager needs to know where that future is in order to fill in
> the result.
>
> Perhaps it's possible to have a stack-allocated future objects that
> consist of just a raw pointer to a block owned by the I/O manager.  But
> these would need to have by-move semantics in order to emulate behavior of
> unique pointers.   I am not entirely sure how by-move vs by-copy is
> decided, but according to 
> this<http://static.rust-lang.org/doc/rust.html#moved-and-copied-types>Rust 
> would choose by-copy.
>
> Vadim
>
>

Actually, I was more thinking of reserving space on the stack for the
return value and have to IO layer write directly into that space (akin to
C++'s Return Value Optimization).

However I might be stumbling on ABI issues here, since it essentially means
that the compiler transforms "Args... -> ~Future" into "Args..., &mut
Future -> ()".

-- Matthieu
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to