3 ms·
> And from what I've read they are better than Rusts coroutines for this use case Reference please? In what sense are they better, and what makes them better?
by tijsvd 6y ago
> And from what I've read they are better than Rusts coroutines for this use case
Reference please? In what sense are they better, and what makes them better?
- pornel 6y agoRust's Futures don't have asynchronous destructors (I don't know if coroutines do). When a Future is aborted early, it's destroyed immediately with no remorse. This means it can't simply offer its own buffers to the kernel, because the kernel could write back after the Future has been freed. An API contract that includes "just be careful not to do the stupid thing" is not good enough by Rust's standards, so the only way to guarantee safety would be to have Future's destructor wait synchronously until the I/O operation is cancelled on the kernel side, but that's inelegant in an async context.
- drran 6y agoIsn't Future lifetime must be tied to I/O operation, so Future will not outlive I/O operation? Can you post an example, please?
- deleted 6y ago[deleted]
- Matthias247 6y agoC++ coroutines for async functions (returning std::task) seem to have completion semantics (are not randomly interruptible). See eg the APIs in cppcoro. However that is not a general property of c++ coroutines. The generator style coroutines also seem randomly cancellable