4 ms·
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
by mratsim 6y ago
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.
- steveklabnik 6y agoRust never implicitly allocates, even with async/await. I have written Rust programs on a microcontroller with no heap, using async/await for it.
- mratsim 6y agoI don't think I've implied that allocation in Rust was implicit but that's a fair point.
- steveklabnik 6y agoYou 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!