OSSwitchCoroutine DEPRECATED


#include <cafe/os.h>

void OSSwitchCoroutine(OSCoroutine *current, OSCoroutine *next);


current Pointer to current coroutine.
next Pointer to next coroutine.

Return Values



Although the Wii U coroutine API is not considered fully deprecated, it should not be used in new applications; threads should be used instead.

OSSwitchCoroutine saves the state of the currently executing coroutine into the current OSCoroutine. Then it switches to the next coroutine by restoring its state from the next OSCoroutine. If the next coroutine was originally saved by OSSaveCoroutine, then that OSSaveCoroutine will return (void *) 1 when it resumes.

OSSwitchCoroutine will not return until a later call to OSSwitchCoroutine or OSLoadCoroutine in another coroutine switches back to this coroutine.

OSSwitchCoroutine is equivalent to the following.

void OSSwitchCoroutine(OSCoroutine *current, OSCoroutine *next)
    void *rv;

    rv = OSSaveCoroutine(current);
    if(rv == 0) {
	OSLoadCoroutine(next, (void*)1);


Demos are available at the following locations.


Do Not Call From

Deprecated Do not call this function in new code.
Multiple threads This function is not thread-safe.
Callbacks Do not call this function from any callback function.
Interrupt handler Do not call this function from any interrupt handler.
Exception handler Do not call this function from any exception handler.
Multiple Cores Do not call this function from more than one Core.

See Also

Coroutine Overview

Revision History

2013/08/02 Clarify coroutine usage.
2013/05/08 Automated cleanup pass.
2012/08/01 Cleanup Pass.
2011/03/15 Initial version.