A compact implementation to use generators as coroutines.