Cross-Platform Coroutines in C++
By George Frasier, March 01, 2001
Source Code Accompanies This Article. Download It Now.
Coroutines are a natural solution to parsing problems used by assembly-language programmers. George presents a cross-platform coroutine technique for C++.
Mar01: Cross-Platform Coroutines in C++
void CTargetPlatformCoroutine::resume(CCoroutine *other)
{
if (other == this) return;
// Tell the other guy to go.
assert(other->state_);
other->state_->signalToGo();
// Wait until someone tells us to go.
assert(state_);
state_->waitToGo();
}
Example 5: blocking call returns, resume calls waitToGo.