Skip to content

Instantly share code, notes, and snippets.

@laindir
Created August 28, 2013 18:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laindir/6369535 to your computer and use it in GitHub Desktop.
Save laindir/6369535 to your computer and use it in GitHub Desktop.
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