@@ -432,6 +432,18 @@ pub const Lua = struct {
432432 c .lua_closeslot (lua .state , index );
433433 }
434434
435+ /// Resets a thread, cleaning its call stack and closing all pending to-be-closed variables.
436+ /// Returns a status code: LUA_OK for no errors in the thread, or an error status otherwise.
437+ /// In case of error, leaves the error object on the top of the stack.
438+ /// The parameter from represents the coroutine that is resetting L.
439+ /// If there is no such coroutine, this parameter can be NULL.
440+ /// (This function was introduced in release 5.4.6.)
441+ /// See https://www.lua.org/manual/5.4/manual.html#lua_closethread
442+ pub fn closeThread (lua : * Lua , from : ? Lua ) ! void {
443+ if (c .lua_closethread (lua .state , if (from ) | f | f .state else null ) != StatusCode .ok ) return error .Fail ;
444+ }
445+
446+
435447 /// Compares two Lua values
436448 /// Returns true if the value at index1 satisisfies the comparison with the value at index2
437449 /// Returns false otherwise, or if any index is not valid
@@ -987,11 +999,10 @@ pub const Lua = struct {
987999 lua .pop (1 );
9881000 }
9891001
990- /// Resets a thread, cleaning its call stack and closing all pending to-be-closed variables
991- /// Returns an error if an error occured and leaves an error object on top of the stack
1002+ /// This function is deprecated; it is equivalent to closeThread() with from being null.
9921003 /// See https://www.lua.org/manual/5.4/manual.html#lua_resetthread
9931004 pub fn resetThread (lua : * Lua ) ! void {
994- if ( c . lua_resetthread ( lua .state ) != StatusCode . ok ) return error . Fail ;
1005+ return lua .closeThread ( null ) ;
9951006 }
9961007
9971008 /// Starts and resumes a coroutine in the given thread
0 commit comments