Skip to content

Commit

Permalink
TINSEL: Fix/comment CORO_KILL_SELF macro.
Browse files Browse the repository at this point in the history
This reverts 9573b1d, which changed
the behaviour of (among other things) NewScene, which made Discworld
uncompletable. Thanks to digitall for bisection/reproduction.
  • Loading branch information
fuzzie committed Jun 20, 2011
1 parent e17a33c commit 712579f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions engines/tinsel/coroutine.h
Expand Up @@ -181,10 +181,15 @@ class CoroContextHolder {
#define CORO_RESCHEDULE do { g_scheduler->reschedule(); CORO_SLEEP(1); } while (0)

/**
* Stop the currently running coroutine.
* Stop the currently running coroutine and all calling coroutines.
*
* This sets _sleep to -1 rather than 0 so that the context doesn't get
* deleted by CoroContextHolder, since we want CORO_INVOKE_ARGS to
* propogate the _sleep value and return immediately (the scheduler will
* then delete the entire coroutine's state, including all subcontexts).
*/
#define CORO_KILL_SELF() \
do { if (&coroParam != &nullContext) { coroParam->_sleep = 0; } return; } while (0)
do { if (&coroParam != &nullContext) { coroParam->_sleep = -1; } return; } while (0)


/**
Expand All @@ -196,8 +201,12 @@ class CoroContextHolder {
/**
* Invoke another coroutine.
*
* What makes this tricky is that the coroutine we called my yield/sleep,
* and we need to deal with this adequately.
* If the subcontext still exists after the coroutine is invoked, it has
* either yielded/slept or killed itself, and so we copy the _sleep value
* to our own context and return (execution will continue at the case
* statement below, where we loop and call the coroutine again).
* If the subcontext is null, the coroutine ended normally, and we can
* simply break out of the loop and continue execution.
*
* @param subCoro name of the coroutine-enabled function to invoke
* @param ARGS list of arguments to pass to subCoro
Expand Down

0 comments on commit 712579f

Please sign in to comment.