diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-17 10:26:39 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-17 10:26:39 +0200 |
commit | 38a4b6b252dd46dc00e1871886e35c196ed1f245 (patch) | |
tree | 248bf37f0e4ae12c336432ef346b2c43ce3c6692 /src | |
parent | 3dd36a796c9258f552c893d225e0d9cc0f576a6d (diff) | |
download | lanes-38a4b6b252dd46dc00e1871886e35c196ed1f245.tar.gz lanes-38a4b6b252dd46dc00e1871886e35c196ed1f245.tar.bz2 lanes-38a4b6b252dd46dc00e1871886e35c196ed1f245.zip |
Lane::close()
Diffstat (limited to 'src')
-rw-r--r-- | src/lane.cpp | 11 | ||||
-rw-r--r-- | src/lane.h | 1 |
2 files changed, 5 insertions, 7 deletions
diff --git a/src/lane.cpp b/src/lane.cpp index 57e3454..7165e85 100644 --- a/src/lane.cpp +++ b/src/lane.cpp | |||
@@ -190,8 +190,7 @@ LUAG_FUNC(thread_join) | |||
190 | LUA_ASSERT(L_, false); | 190 | LUA_ASSERT(L_, false); |
191 | _ret = 0; | 191 | _ret = 0; |
192 | } | 192 | } |
193 | lua_close(_L2); | 193 | _lane->close(); |
194 | _lane->L = nullptr; | ||
195 | STACK_CHECK(L_, _ret); | 194 | STACK_CHECK(L_, _ret); |
196 | return _ret; | 195 | return _ret; |
197 | } | 196 | } |
@@ -683,8 +682,7 @@ static void lane_main(Lane* lane_) | |||
683 | lane_->waiting_on = nullptr; // just in case | 682 | lane_->waiting_on = nullptr; // just in case |
684 | if (selfdestruct_remove(lane_)) { // check and remove (under lock!) | 683 | if (selfdestruct_remove(lane_)) { // check and remove (under lock!) |
685 | // We're a free-running thread and no-one's there to clean us up. | 684 | // We're a free-running thread and no-one's there to clean us up. |
686 | lua_close(lane_->L); | 685 | lane_->close(); |
687 | lane_->L = nullptr; // just in case | ||
688 | lane_->U->selfdestructMutex.lock(); | 686 | lane_->U->selfdestructMutex.lock(); |
689 | // done with lua_close(), terminal shutdown sequence may proceed | 687 | // done with lua_close(), terminal shutdown sequence may proceed |
690 | lane_->U->selfdestructingCount.fetch_sub(1, std::memory_order_release); | 688 | lane_->U->selfdestructingCount.fetch_sub(1, std::memory_order_release); |
@@ -752,9 +750,8 @@ static void lane_main(Lane* lane_) | |||
752 | return 0; | 750 | return 0; |
753 | } else if (_lane->L) { | 751 | } else if (_lane->L) { |
754 | // no longer accessing the Lua VM: we can close right now | 752 | // no longer accessing the Lua VM: we can close right now |
755 | lua_close(_lane->L); | 753 | _lane->close(); |
756 | _lane->L = nullptr; | 754 | // just in case, but _lane will be freed soon so... |
757 | // just in case, but s will be freed soon so... | ||
758 | _lane->debugName = "<gc>"; | 755 | _lane->debugName = "<gc>"; |
759 | } | 756 | } |
760 | 757 | ||
@@ -119,6 +119,7 @@ class Lane | |||
119 | ~Lane(); | 119 | ~Lane(); |
120 | 120 | ||
121 | void changeDebugName(int nameIdx_); | 121 | void changeDebugName(int nameIdx_); |
122 | void close() { lua_State* _L{ L }; L = nullptr; lua_close(_L); } | ||
122 | void pushThreadStatus(lua_State* L_) const; | 123 | void pushThreadStatus(lua_State* L_) const; |
123 | void securizeDebugName(lua_State* L_); | 124 | void securizeDebugName(lua_State* L_); |
124 | void startThread(int priority_); | 125 | void startThread(int priority_); |