[fpc-pascal] Coroutines and VirtualAlloc
denisgolovan at yandex.ru
Thu Apr 20 11:06:22 CEST 2017
20.04.2017, 11:43, "Ryan Joseph" <ryan at thealchemistguild.com>:
>> On Apr 20, 2017, at 3:01 PM, Bernd Mueller <mueller.b at gmx.net> wrote:
>> it would be really nice to have coroutines for the embedded targets like AVR and ARM.
> What are people using this for btw? Personally I wanted them to solve some problems in game programming where I lots of nested loops that need to be synched with a main loop and can’t block.
It is especially favorable for game development.
All processes/objects which live across several rendering frames and have any state are greatly simplified by coroutines.
e.g. living entities, animations, any game triggers, any finite state machines, etc.
Proper implemented coroutines support thousands of instances.
With proper (read "mostly functional"/non-shared data) approach coroutines might also be calculated within real threads in parallel.
Another example is network-related code (both client and server code).
Break your huge finite state machines into pipeline stages via coroutines and it gets pretty modular, extensive and simple to reason about.
To say to generally, had we had coroutines in first place, no OOP crap would be necessary :)
At least in game development.
More information about the fpc-pascal