aboutsummaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-12-13 13:07:53 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-12-13 13:07:53 -0200
commitfdc25a1ebfe9968dcec390dd556375105aa0be40 (patch)
tree43759131636a501ec92475d453fd1a1c73bc8090 /manual
parent3b06f983ae0e57b90cdeb500c84bb524e5c3635b (diff)
downloadlua-fdc25a1ebfe9968dcec390dd556375105aa0be40.tar.gz
lua-fdc25a1ebfe9968dcec390dd556375105aa0be40.tar.bz2
lua-fdc25a1ebfe9968dcec390dd556375105aa0be40.zip
New functions 'lua_resetthread' and 'coroutine.kill'
New functions to reset/kill a thread/coroutine, mainly (only?) to close any pending to-be-closed variable. ('lua_resetthread' also allows a thread to be reused...)
Diffstat (limited to 'manual')
-rw-r--r--manual/manual.of34
1 files changed, 30 insertions, 4 deletions
diff --git a/manual/manual.of b/manual/manual.of
index 0e8e3d72..862d032b 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -3927,6 +3927,19 @@ and then pops the top element.
3927 3927
3928} 3928}
3929 3929
3930@APIEntry{int lua_resetthread (lua_State *L);|
3931@apii{0,?,-}
3932
3933Resets a thread, cleaning its call stack and closing all pending
3934to-be-closed variables.
3935Returns a status code:
3936@Lid{LUA_OK} for no errors in closing methods,
3937or an error status otherwise.
3938In case of error,
3939leave the error object on the stack,
3940
3941}
3942
3930@APIEntry{int lua_resume (lua_State *L, lua_State *from, int nargs, 3943@APIEntry{int lua_resume (lua_State *L, lua_State *from, int nargs,
3931 int *nresults);| 3944 int *nresults);|
3932@apii{?,?,-} 3945@apii{?,?,-}
@@ -3948,11 +3961,8 @@ or returned by the body function.
3948@Lid{LUA_OK} if the coroutine finishes its execution 3961@Lid{LUA_OK} if the coroutine finishes its execution
3949without errors, 3962without errors,
3950or an error code in case of errors @seeC{lua_pcall}. 3963or an error code in case of errors @seeC{lua_pcall}.
3951
3952In case of errors, 3964In case of errors,
3953the stack is not unwound, 3965the error object is on the top of the stack.
3954so you can use the debug API over it.
3955The error object is on the top of the stack.
3956 3966
3957To resume a coroutine, 3967To resume a coroutine,
3958you remove all results from the last @Lid{lua_yield}, 3968you remove all results from the last @Lid{lua_yield},
@@ -6285,6 +6295,17 @@ it is not inside a non-yieldable @N{C function}.
6285 6295
6286} 6296}
6287 6297
6298@LibEntry{coroutine.kill(co)|
6299
6300Kills coroutine @id{co},
6301closing all its pending to-be-closed variables
6302and putting the coroutine in a dead state.
6303In case of error closing some variable,
6304returns @false plus the error object;
6305otherwise returns @true.
6306
6307}
6308
6288@LibEntry{coroutine.resume (co [, val1, @Cdots])| 6309@LibEntry{coroutine.resume (co [, val1, @Cdots])|
6289 6310
6290Starts or continues the execution of coroutine @id{co}. 6311Starts or continues the execution of coroutine @id{co}.
@@ -8648,6 +8669,11 @@ has been removed.
8648When needed, this metamethod must be explicitly defined. 8669When needed, this metamethod must be explicitly defined.
8649} 8670}
8650 8671
8672@item{
8673When a coroutine finishes with an error,
8674its stack is unwound (to run any pending closing methods).
8675}
8676
8651} 8677}
8652 8678
8653} 8679}