Re:ProtoThreads: Lightweight, Stackless Threads in C
by fjfaase on Monday September 23, 2019 @05:54AM
(#21047370)
Actually, 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.
Re:ProtoThreads: Lightweight, Stackless Threads in C
by Squonk42 on Monday September 23, 2019 @01:02AM
(#21046039)
Yes, and here is an implementation:
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.
So if it's still single-threaded, then this is basically a cumbersome async/await right?