Created
February 24, 2011 21:48
-
-
Save mraleph/842959 to your computer and use it in GitHub Desktop.
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
static coroutine* curr_coroutine; // getspecific, setspecific use this global var to know what is running | |
void resume (coroutine* target) { | |
coroutine* self = curr_coroutine; | |
{ Unlocker unlocker; // archive currently running coroutine | |
curr_coroutine = target; | |
switch_context(target); | |
current_coroutine = self; | |
} // here ~Unlocker will restore information from curr_coroutine. | |
} | |
// this is a coroutine entry point | |
void entry (coroutine* self) { | |
curr_coroutine = self; | |
{ Locker lock; // we are entering new coroutine | |
invoke_javascript_code(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment