public final class CoroutineLib extends Object
coroutine. See §2.6 of the Lua Reference Manual for a general description of coroutines.| Modifier and Type | Method and Description |
|---|---|
static org.classdump.luna.runtime.LuaFunction |
create()
Returns the function
coroutine.create. |
static void |
installInto(org.classdump.luna.StateContext context,
org.classdump.luna.Table env)
Installs the coroutine library to the global environment
env in the state
context context. |
static org.classdump.luna.runtime.LuaFunction |
isyieldable()
Returns the function
coroutine.isyieldable. |
static org.classdump.luna.runtime.LuaFunction |
resume()
Returns the function
coroutine.resume. |
static org.classdump.luna.runtime.LuaFunction |
running()
Returns the function
coroutine.running. |
static org.classdump.luna.runtime.LuaFunction |
status()
Returns the function
coroutine.status. |
static org.classdump.luna.runtime.LuaFunction |
wrap()
Returns the function
coroutine.wrap. |
static org.classdump.luna.runtime.LuaFunction |
yield()
Returns the function
coroutine.yield. |
public static org.classdump.luna.runtime.LuaFunction create()
coroutine.create.
The following is the corresponding entry from the Lua Reference Manual:
coroutine.create (f)Creates a new coroutine, with body
f.fmust be a function. Returns this new coroutine, an object with type"thread".
coroutine.create functioncoroutine.createpublic static org.classdump.luna.runtime.LuaFunction isyieldable()
coroutine.isyieldable.
The following is the corresponding entry from the Lua Reference Manual:
coroutine.isyieldable ()Returns true when the running coroutine can yield.
A running coroutine is yieldable if it is not the main thread and it is not inside a non-yieldable C function.
coroutine.isyieldable functioncoroutine.isyieldablepublic static org.classdump.luna.runtime.LuaFunction resume()
coroutine.resume.
The following is the corresponding entry from the Lua Reference Manual:
coroutine.resume (co [, val1, ···])Starts or continues the execution of coroutine
co. The first time you resume a coroutine, it starts running its body. The valuesval1, ... are passed as the arguments to the body function. If the coroutine has yielded,resumerestarts it; the valuesval1, ... are passed as the results from the yield.If the coroutine runs without any errors,
resumereturns true plus any values passed toyield(when the coroutine yields) or any values returned by the body function (when the coroutine terminates). If there is any error,resumereturns false plus the error message.
coroutine.resume functioncoroutine.resumepublic static org.classdump.luna.runtime.LuaFunction running()
coroutine.running.
The following is the corresponding entry from the Lua Reference Manual:
coroutine.running ()Returns the running coroutine plus a boolean, true when the running coroutine is the main one.
coroutine.running functioncoroutine.runningpublic static org.classdump.luna.runtime.LuaFunction status()
coroutine.status.
The following is the corresponding entry from the Lua Reference Manual:
coroutine.status (co)Returns the status of coroutine
co, as a string:"running", if the coroutine is running (that is, it calledstatus);"suspended", if the coroutine is suspended in a call toyield, or if it has not started running yet;"normal"if the coroutine is active but not running (that is, it has resumed another coroutine); and"dead"if the coroutine has finished its body function, or if it has stopped with an error.
coroutine.status functioncoroutine.statuspublic static org.classdump.luna.runtime.LuaFunction wrap()
coroutine.wrap.
The following is the corresponding entry from the Lua Reference Manual:
coroutine.wrap (f)Creates a new coroutine, with body
f.fmust be a function. Returns a function that resumes the coroutine each time it is called. Any arguments passed to the function behave as the extra arguments toresume. Returns the same values returned byresume, except the first boolean. In case of error, propagates the error.
coroutine.wrap functioncoroutine.wrappublic static org.classdump.luna.runtime.LuaFunction yield()
coroutine.yield.
The following is the corresponding entry from the Lua Reference Manual:
coroutine.yield (···)Suspends the execution of the calling coroutine. Any arguments to
yieldare passed as extra results toresume.
coroutine.yield functioncoroutine.yieldpublic static void installInto(org.classdump.luna.StateContext context,
org.classdump.luna.Table env)
env in the state
context context.
If env.package.loaded is a table, adds the library table
to it with the key "coroutine", using raw access.
context - the state context, must not be nullenv - the global environment, must not be nullNullPointerException - if context or env is nullCopyright © 2016–2017. All rights reserved.