Coroutine<T>
package lua
extends Thread
Available on lua
Externs for native Lua coroutines.
Static methods
staticcreate<T>(f:T):Coroutine<T>
Creates a new coroutine, with body f
. f
must be a Lua function.
staticresume<A, B>(c:Coroutine<Dynamic>, args:Rest<A>):CoroutineResume<B>
Starts or continues the execution of coroutine. The first time you resume a coroutine, it starts running its body. The values args
are passed as the arguments to the body function. If the coroutine has yielded, resume
restarts it; the values args
are passed as the results from the yield.
If the coroutine runs without any errors, resume
returns true
plus any values passed to yield
(if the coroutine yields) or any values returned by the body function (if the coroutine terminates). If there is any error, resume
returns false
plus the error message.
staticrunning():CoroutineRunning
Returns the running coroutine plus a boolean, true when the running coroutine is the main one.
staticstatus(c:Coroutine<Dynamic>):CoroutineState
Returns the status of coroutine.
staticwrap<T>(f:T):T
Creates a new coroutine, with body f
. Returns a function that resumes the coroutine each time it is called. Any arguments passed to the function behave as the extra arguments to resume
. Returns the same values returned by resume
, except the first boolean. In case of error, propagates the error.
staticyield<T>(args:Rest<Dynamic>):T
Suspends the execution of the calling coroutine. The coroutine cannot be running a C function, a metamethod, or an iterator. Any arguments to yield
are passed as extra results to resume
.
© 2005–2020 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/lua/Coroutine.html