From f1c3401e80a3228ee3ef5110e73712e1aa879fca Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Wed, 12 Jun 2024 08:28:01 +0200 Subject: Code boyscouting --- src/lane.cpp | 10 +++++----- src/lane.h | 2 +- src/macros_and_utils.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lane.cpp b/src/lane.cpp index 9751aeb..6f4935e 100644 --- a/src/lane.cpp +++ b/src/lane.cpp @@ -94,7 +94,7 @@ static LUAG_FUNC(set_debug_threadname) // ################################################################################################# //--- -// [...] | [nil, err_any, stack_tbl]= thread_join( lane_ud [, wait_secs=-1] ) +// [...] | [nil, err_any, stack_tbl]= lane:join([wait_secs]) // // timeout: returns nil // done: returns return values (0..N) @@ -114,7 +114,7 @@ static LUAG_FUNC(thread_join) raise_luaL_argerror(L_, 2, "duration cannot be < 0"); } - } else if (!lua_isnoneornil(L_, 2)) { // alternate explicit "infinite timeout" by passing nil before the key + } else if (!lua_isnoneornil(L_, 2)) { raise_luaL_argerror(L_, 2, "incorrect duration type"); } @@ -179,7 +179,7 @@ static LUAG_FUNC(thread_join) LUA_ASSERT(L_, false); _ret = 0; } - _lane->close(); + _lane->closeState(); STACK_CHECK(L_, _ret); return _ret; } @@ -707,7 +707,7 @@ static void lane_main(Lane* lane_) lane_->waiting_on = nullptr; // just in case if (selfdestruct_remove(lane_)) { // check and remove (under lock!) // We're a free-running thread and no-one's there to clean us up. - lane_->close(); + lane_->closeState(); lane_->U->selfdestructMutex.lock(); // done with lua_close(), terminal shutdown sequence may proceed lane_->U->selfdestructingCount.fetch_sub(1, std::memory_order_release); @@ -793,7 +793,7 @@ static LUAG_FUNC(lane_gc) return 0; } else if (_lane->L) { // no longer accessing the Lua VM: we can close right now - _lane->close(); + _lane->closeState(); // just in case, but _lane will be freed soon so... _lane->debugName = std::string_view{ "" }; } diff --git a/src/lane.h b/src/lane.h index 7c75fe8..eb70153 100644 --- a/src/lane.h +++ b/src/lane.h @@ -129,7 +129,7 @@ class Lane CancelResult cancel(CancelOp op_, int hookCount_, std::chrono::time_point until_, bool wakeLane_); void changeDebugName(int const nameIdx_); - void close() { lua_State* _L{ L }; L = nullptr; lua_close(_L); } + void closeState() { lua_State* _L{ L }; L = nullptr; lua_close(_L); } [[nodiscard]] std::string_view errorTraceLevelString() const; [[nodiscard]] int pushErrorHandler() const; [[nodiscard]] std::string_view pushErrorTraceLevel(lua_State* L_) const; diff --git a/src/macros_and_utils.h b/src/macros_and_utils.h index 1c4457a..787cf03 100644 --- a/src/macros_and_utils.h +++ b/src/macros_and_utils.h @@ -16,7 +16,7 @@ inline void STACK_GROW(lua_State* L_, int n_) // ################################################################################################# -#define LUAG_FUNC(func_name) [[nodiscard]] int LG_##func_name(lua_State* const L_) +#define LUAG_FUNC(func_name) int LG_##func_name(lua_State* const L_) // ################################################################################################# -- cgit v1.2.3-55-g6feb