4 ms·
> Protothreads can be used with or without an underlying operating system to provide blocking event-handlers. Protothreads provide sequential flow of control wi
by gitgud 7y ago
> Protothreads can be used with or without an underlying operating system to provide blocking event-handlers. Protothreads provide sequential flow of control without complex state machines or full multi-threading.
So if it's still single-threaded, then this is basically a cumbersome async/await right?
- Squonk42 7y agoYes, and here is an implementation: https://github.com/naasking/async.h https://github.com/naasking/async.h Duff’s device along with the __LINE__ trick enables the creation of automatic DFAs useful to generate coroutines, protothreads and async/await alike.
- fjfaase 7y agoActually, it is a way to represent state machines as 'code'. It is a way of seperating the data from the functions, such that the functions can be 'stopped' and 'continued' in the middle (turning them into coroutines). Each stop point (often hidden in an await) is a state of the state machine represented by the function.