Re:Protothreads: Lightweight Stackless Threads in C
by dnlgl on Thursday May 16, 2019 @05:59AM
(#19927585)
Quite the opposite, actually. He said that he will probably be fired, but should still insist on it being the right way:
"Any coding standard which insists on syntactic clarity at the expense of algorithmic clarity should be rewritten. If your employer fires you for using this trick, tell them that repeatedly as the security staff drag you out of the building."
https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
[ Parent
| on HN ]
Re:Protothreads: Lightweight Stackless Threads in C
by manwe150 on Thursday May 16, 2019 @11:34AM
(#19929940)
Excitingly, we soon may be able to have both (if you can compile your C code with a C++ compiler). Coroutines are in the working draft for the C++20 spec, so they may soon be provided by the runtime (and thus integrate into all of the other language features and syntax) instead of requiring hacking it up with string macros: https://en.cppreference.com/w/cpp/language/coroutines
Re:Protothreads: Lightweight Stackless Threads in C
by alexhutcheson on Thursday May 16, 2019 @01:30PM
(#19930980)
If you want coroutines before upgrading to a C++20 toolchain, you can also try:
- boost::Fiber for C++: https://www.boost.org/doc/libs/1_70_0/libs/fiber/doc/html/in...
- boost::coroutine2 for C++: https://www.boost.org/doc/libs/1_70_0/libs/coroutine2/doc/ht... (lower level than boost::Fiber, and doesn't include an internal scheduler)
- libtask for C: https://swtch.com/libtask/
In the C++ context, this doc summarizes the distinction between "fibers" and "coroutines", although the terminology is not consistent across language ecosystems: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n402...