@@ -432,6 +432,18 @@ pub const Lua = struct {
432
432
c .lua_closeslot (lua .state , index );
433
433
}
434
434
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
+
435
447
/// Compares two Lua values
436
448
/// Returns true if the value at index1 satisisfies the comparison with the value at index2
437
449
/// Returns false otherwise, or if any index is not valid
@@ -987,11 +999,10 @@ pub const Lua = struct {
987
999
lua .pop (1 );
988
1000
}
989
1001
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.
992
1003
/// See https://www.lua.org/manual/5.4/manual.html#lua_resetthread
993
1004
pub fn resetThread (lua : * Lua ) ! void {
994
- if ( c . lua_resetthread ( lua .state ) != StatusCode . ok ) return error . Fail ;
1005
+ return lua .closeThread ( null ) ;
995
1006
}
996
1007
997
1008
/// Starts and resumes a coroutine in the given thread
0 commit comments