digitalmars.D.learn - Using fibers
- solidstate1991 (17/17) Aug 03 2018 I'm porting LZHAM to D, and the original used some very unusual
I'm porting LZHAM to D, and the original used some very unusual approach for coroutines: - the whole thing is running inside of a single switch-case block created by C++ macros - the function saves some local values - a macro sets the state variable to the current line number, returns the status (eg. if compression error happened or the decompressor needs more data), then the function can be continued from a new case block labelled by __LINE__ I started to switch out error codes with exceptions, at least they also provide more information besides what happened, but don't know what should the fate of the other status codes be. I probably making them derived from the Throwable class to distinguish them from the error codes, or put delegates in place of them. I hope the Fiber class will eliminate the ugliness of the macro-generated switch-case block, and make the code easier to read and debug.
Aug 03 2018