Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It requires allocation if the coroutine outlives the scope that created it.

Otherwise compiler are free to implement heap allocation elision (which is done in Clang).

Now compared to Rust, assuming you have a series of coroutines to process a deferred event, Rust will allocate once for the whole series while C++ would allocate once per coroutine to store them in the reactor/proactor.



Rust never implicitly allocates, even with async/await. I have written Rust programs on a microcontroller with no heap, using async/await for it.


I don't think I've implied that allocation in Rust was implicit but that's a fair point.


You said

> Rust will allocate once for the whole series

which, it will not.

It is true that some executors will do a single allocation for the whole series, but that is not done by Rust, nor is required. That's all!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: