4 ms·
ProtoThreads can use Duff's device to implement its "local continuations", but it's not the only implementation. There's an alternate one that uses the "labels
by mrpippy 7y ago
ProtoThreads can use Duff's device to implement its "local continuations", but it's not the only implementation.
There's an alternate one that uses the "labels as values" feature supported by GCC and Clang, which is much more elegant. In particular, it allows you to have a 'switch' statement inside the protothread.
- gpderetta 7y agoI've tried that, but unfortunately, at least on GCC, taking the address of a label suppresses inlining of the containing function (which is important of you are trying to implement generators, less critical for async functions), so it often generate worst code than the switch statement implementation.