Coroutine - mfichman/jogo GitHub Wiki

Implements a coroutine, or lightweight cooperative thread. The coroutine semantics implemented by this class is intended to be similar to Lua's implementation. Calling the coroutine after it has been created begins executing the coroutine. After a coroutine is finished, calling it again has no effect. A coroutine can yield at any point using the yield() function, which returns control to caller of the coroutine. Resuming causes the execution of the coroutine to continue from the last call to yield().

@init(start CoroutineFunc)

Initializes a new coroutine, but does not begin executing it. The coroutine will execute 'start' the first time it is run.

@destroy()

Deallocates the coroutine, and releases the closure.

@call()

This function starts or resumes a coroutine. If the coroutine is new, then the execution begins starting at 'function'. If the coroutine is dead, then this function has no effect. Otherwise, the execution resumes from the last yield.

resume()

This function starts or resumes a coroutine. If the coroutine is new, then the execution begins starting at 'function'. If the coroutine is dead, then this function has no effect. Otherwise, the execution resumes from the last yield.

status?() CoroutineStatus

No comment

function?() CoroutineFunc

No comment

stack_size?() Int

No comment