aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-06-12 08:28:01 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-06-12 08:28:01 +0200
commitf1c3401e80a3228ee3ef5110e73712e1aa879fca (patch)
tree95d337e8f3b19cc0d13902222968f21a949d38c0
parent9b78a51e6eb060ce0bee664d18facc656135035a (diff)
downloadlanes-f1c3401e80a3228ee3ef5110e73712e1aa879fca.tar.gz
lanes-f1c3401e80a3228ee3ef5110e73712e1aa879fca.tar.bz2
lanes-f1c3401e80a3228ee3ef5110e73712e1aa879fca.zip
Code boyscouting
-rw-r--r--src/lane.cpp10
-rw-r--r--src/lane.h2
-rw-r--r--src/macros_and_utils.h2
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)
94// ################################################################################################# 94// #################################################################################################
95 95
96//--- 96//---
97// [...] | [nil, err_any, stack_tbl]= thread_join( lane_ud [, wait_secs=-1] ) 97// [...] | [nil, err_any, stack_tbl]= lane:join([wait_secs])
98// 98//
99// timeout: returns nil 99// timeout: returns nil
100// done: returns return values (0..N) 100// done: returns return values (0..N)
@@ -114,7 +114,7 @@ static LUAG_FUNC(thread_join)
114 raise_luaL_argerror(L_, 2, "duration cannot be < 0"); 114 raise_luaL_argerror(L_, 2, "duration cannot be < 0");
115 } 115 }
116 116
117 } else if (!lua_isnoneornil(L_, 2)) { // alternate explicit "infinite timeout" by passing nil before the key 117 } else if (!lua_isnoneornil(L_, 2)) {
118 raise_luaL_argerror(L_, 2, "incorrect duration type"); 118 raise_luaL_argerror(L_, 2, "incorrect duration type");
119 } 119 }
120 120
@@ -179,7 +179,7 @@ static LUAG_FUNC(thread_join)
179 LUA_ASSERT(L_, false); 179 LUA_ASSERT(L_, false);
180 _ret = 0; 180 _ret = 0;
181 } 181 }
182 _lane->close(); 182 _lane->closeState();
183 STACK_CHECK(L_, _ret); 183 STACK_CHECK(L_, _ret);
184 return _ret; 184 return _ret;
185} 185}
@@ -707,7 +707,7 @@ static void lane_main(Lane* lane_)
707 lane_->waiting_on = nullptr; // just in case 707 lane_->waiting_on = nullptr; // just in case
708 if (selfdestruct_remove(lane_)) { // check and remove (under lock!) 708 if (selfdestruct_remove(lane_)) { // check and remove (under lock!)
709 // We're a free-running thread and no-one's there to clean us up. 709 // We're a free-running thread and no-one's there to clean us up.
710 lane_->close(); 710 lane_->closeState();
711 lane_->U->selfdestructMutex.lock(); 711 lane_->U->selfdestructMutex.lock();
712 // done with lua_close(), terminal shutdown sequence may proceed 712 // done with lua_close(), terminal shutdown sequence may proceed
713 lane_->U->selfdestructingCount.fetch_sub(1, std::memory_order_release); 713 lane_->U->selfdestructingCount.fetch_sub(1, std::memory_order_release);
@@ -793,7 +793,7 @@ static LUAG_FUNC(lane_gc)
793 return 0; 793 return 0;
794 } else if (_lane->L) { 794 } else if (_lane->L) {
795 // no longer accessing the Lua VM: we can close right now 795 // no longer accessing the Lua VM: we can close right now
796 _lane->close(); 796 _lane->closeState();
797 // just in case, but _lane will be freed soon so... 797 // just in case, but _lane will be freed soon so...
798 _lane->debugName = std::string_view{ "<gc>" }; 798 _lane->debugName = std::string_view{ "<gc>" };
799 } 799 }
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
129 129
130 CancelResult cancel(CancelOp op_, int hookCount_, std::chrono::time_point<std::chrono::steady_clock> until_, bool wakeLane_); 130 CancelResult cancel(CancelOp op_, int hookCount_, std::chrono::time_point<std::chrono::steady_clock> until_, bool wakeLane_);
131 void changeDebugName(int const nameIdx_); 131 void changeDebugName(int const nameIdx_);
132 void close() { lua_State* _L{ L }; L = nullptr; lua_close(_L); } 132 void closeState() { lua_State* _L{ L }; L = nullptr; lua_close(_L); }
133 [[nodiscard]] std::string_view errorTraceLevelString() const; 133 [[nodiscard]] std::string_view errorTraceLevelString() const;
134 [[nodiscard]] int pushErrorHandler() const; 134 [[nodiscard]] int pushErrorHandler() const;
135 [[nodiscard]] std::string_view pushErrorTraceLevel(lua_State* L_) const; 135 [[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_)
16 16
17// ################################################################################################# 17// #################################################################################################
18 18
19#define LUAG_FUNC(func_name) [[nodiscard]] int LG_##func_name(lua_State* const L_) 19#define LUAG_FUNC(func_name) int LG_##func_name(lua_State* const L_)
20 20
21// ################################################################################################# 21// #################################################################################################
22 22