Skip to content

Instantly share code, notes, and snippets.

@laindir
Created Aug 28, 2013
Embed
What would you like to do?
Simon Tatham/Tom Duff style coroutines
#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