| ▲ | whizzter 2 hours ago | |
Kinda disagree here about the "elegantness", superficially it's an elegant abstraction to unify generator-like coroutines and "tasks". In practice it's bad, a generator (co_yield) is often an encapsulated object that will have a non-deterministic lifetime, thus it cannot be put into a fifo. "Tasks" however (co_await / co_return) often live on a stack-fifo that could've been mixed with partial bump-allocators to allow pointer-stability for the stack-frame (there is kind of the machinery via the new overloading for the promise), but due to varying lifetimes it easily becomes a mess (Looked at some other task library that seemingly had low allocations like this but it feels like the entire machinery can easily break with "careless" usage). And I think that's a part of why std::execution feels like a mess, it tries to make coroutines in task settings more "usable" for those writing things around tasks, but it doesn't really decide on a coherent direction for tasks (since the language primitive was left too abstract/messy). | ||
| ▲ | nly 2 hours ago | parent [-] | |
I'm not too familiar with generators. I've never really had much use for them. I've used co_yield once successfully to interleave two separate tree recursions in lock-step and I don't remember any issues. It's also not at clear to me why you'd want to put a generator into a fifo. Any succinct code snippets that demonstrate the issue? | ||