diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-07-29 18:07:16 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-07-29 18:07:16 +0200 |
commit | bb11006f635a69dd9244e09e4359ed02eff8fe84 (patch) | |
tree | 7fda9eda216b1683ff3dd954b6300c13bfaf2b14 /src/lane.h | |
parent | 34b2b5e712ea1cc59004ca48f79f54af162993a5 (diff) | |
download | lanes-bb11006f635a69dd9244e09e4359ed02eff8fe84.tar.gz lanes-bb11006f635a69dd9244e09e4359ed02eff8fe84.tar.bz2 lanes-bb11006f635a69dd9244e09e4359ed02eff8fe84.zip |
Internal refactorization to properly handle lua_resume idiosyncrasies
Diffstat (limited to 'src/lane.h')
-rw-r--r-- | src/lane.h | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -99,6 +99,7 @@ class Lane | |||
99 | Universe* const U{}; | 99 | Universe* const U{}; |
100 | lua_State* S{}; // the master state of the lane | 100 | lua_State* S{}; // the master state of the lane |
101 | lua_State* L{}; // the state we run things in (either S or a lua_newthread() state if we run in coroutine mode) | 101 | lua_State* L{}; // the state we run things in (either S or a lua_newthread() state if we run in coroutine mode) |
102 | int nresults{}; // number of results to extract from the stack (can differ from the actual number of values when in coroutine mode) | ||
102 | // | 103 | // |
103 | // M: prepares the state, and reads results | 104 | // M: prepares the state, and reads results |
104 | // S: while S is running, M must keep out of modifying the state | 105 | // S: while S is running, M must keep out of modifying the state |
@@ -148,13 +149,10 @@ class Lane | |||
148 | void changeDebugName(int const nameIdx_); | 149 | void changeDebugName(int const nameIdx_); |
149 | void closeState() | 150 | void closeState() |
150 | { | 151 | { |
151 | { | ||
152 | std::lock_guard<std::mutex> _guard{ debugNameMutex }; | ||
153 | debugName = std::string_view{ "<gc>" }; | ||
154 | } | ||
155 | lua_State* _L{ S }; | 152 | lua_State* _L{ S }; |
156 | S = nullptr; | 153 | S = nullptr; |
157 | L = nullptr; | 154 | L = nullptr; |
155 | nresults = 0; | ||
158 | lua_close(_L); // this collects our coroutine thread at the same time | 156 | lua_close(_L); // this collects our coroutine thread at the same time |
159 | } | 157 | } |
160 | [[nodiscard]] std::string_view errorTraceLevelString() const; | 158 | [[nodiscard]] std::string_view errorTraceLevelString() const; |
@@ -174,9 +172,11 @@ class Lane | |||
174 | [[nodiscard]] std::string_view pushErrorTraceLevel(lua_State* L_) const; | 172 | [[nodiscard]] std::string_view pushErrorTraceLevel(lua_State* L_) const; |
175 | static void PushMetatable(lua_State* L_); | 173 | static void PushMetatable(lua_State* L_); |
176 | void pushStatusString(lua_State* L_) const; | 174 | void pushStatusString(lua_State* L_) const; |
175 | void pushIndexedResult(lua_State* L_, int key_) const; | ||
177 | void resetResultsStorage(lua_State* const L_, int gc_cb_idx_); | 176 | void resetResultsStorage(lua_State* const L_, int gc_cb_idx_); |
178 | void securizeDebugName(lua_State* L_); | 177 | void securizeDebugName(lua_State* L_); |
179 | void startThread(int priority_); | 178 | void startThread(int priority_); |
179 | [[nodiscard]] int storeResults(lua_State* L_); | ||
180 | [[nodiscard]] std::string_view threadStatusString() const; | 180 | [[nodiscard]] std::string_view threadStatusString() const; |
181 | // wait until the lane stops working with its state (either Suspended or Done+) | 181 | // wait until the lane stops working with its state (either Suspended or Done+) |
182 | [[nodiscard]] bool waitForCompletion(std::chrono::time_point<std::chrono::steady_clock> until_); | 182 | [[nodiscard]] bool waitForCompletion(std::chrono::time_point<std::chrono::steady_clock> until_); |