Proposal: coroutine API instead of cooperative scheduler #1320
Replies: 2 comments 3 replies
-
Yeah, definitely 😅 but it was good enough for the purpose in the C++17 era. 💪
I'm more than happy to continue the discussion. I haven't had much use for coroutines since they've been around, so feel free to lead the discussion and talk to me like a 3yo. 😅 |
Beta Was this translation helpful? Give feedback.
-
Scheduler can stay around forever. Nothing against it really :).
How about
I'll attach a document on how they work and why use coroutines, but the best resource really is this blog. I'm happy to answer any questions, I know they can be confusing at first since it's a lot of new concepts. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Since EnTT is using C++20 now, an interesting feature for gamedev is coroutines. EnTT already has a "manual" alternative to them in the form of
basic_process, but I would argue it's not the best we can do.Coroutines allow for a clean way to schedule things to be run each
update, freely passing any context around (no need to remember what yourvoid *was exactly), waiting for events to happen, waiting for other "process"-es to finish, etc. Hence, I propose a new API that allows to schedule coroutines to be run eachupdatewhere you can even bring-your-own coroutine types.Reference implementation: link.
I would be happy to discuss this more in details and also how this and coroutines work internally. In the code,
linear_schedulerandexecutor<Delta>are separate just so that events don't have to "care" about the delta type.Note that this implementation is mostly for demonstration purposes and not fully complete yet. Things that are still to discuss/implement are:
processAPI non-negotiable? it can be emulated for needed cases by using atask<exit_status>at no extra costBeta Was this translation helpful? Give feedback.
All reactions