Created
August 28, 2013 18:32
-
-
Save laindir/6369535 to your computer and use it in GitHub Desktop.
Simon Tatham/Tom Duff style coroutines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef COROUTINE_H | |
#define COROUTINE_H | |
#define start(state) switch(state) { case 0:; | |
#define finish default:; } | |
/*save state and return value*/ | |
#define yield(state,value) do { state = __LINE__; return (value); case __LINE__:; } while (0) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment