diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-07-03 13:21:45 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-07-03 13:21:45 +0200 |
commit | ffedd175233975f3ca9ac940df9883898d5ace25 (patch) | |
tree | a073d90a98b188635b19027d797e2c8b663501e0 /src/lane.h | |
parent | f81fe873dd24f93306f0f667fc47766990a9321b (diff) | |
download | lanes-ffedd175233975f3ca9ac940df9883898d5ace25.tar.gz lanes-ffedd175233975f3ca9ac940df9883898d5ace25.tar.bz2 lanes-ffedd175233975f3ca9ac940df9883898d5ace25.zip |
Renamed set_debug_threadname → lane_threadname (can also read the current name now)
Diffstat (limited to 'src/lane.h')
-rw-r--r-- | src/lane.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -89,8 +89,13 @@ class Lane | |||
89 | // M: sub-thread OS thread | 89 | // M: sub-thread OS thread |
90 | // S: not used | 90 | // S: not used |
91 | 91 | ||
92 | private: | ||
93 | |||
94 | mutable std::mutex debugNameMutex; | ||
92 | std::string_view debugName{ "<unnamed>" }; | 95 | std::string_view debugName{ "<unnamed>" }; |
93 | 96 | ||
97 | public: | ||
98 | |||
94 | Universe* const U{}; | 99 | Universe* const U{}; |
95 | lua_State* S{}; // the master state of the lane | 100 | lua_State* S{}; // the master state of the lane |
96 | 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) |
@@ -143,12 +148,21 @@ class Lane | |||
143 | void changeDebugName(int const nameIdx_); | 148 | void changeDebugName(int const nameIdx_); |
144 | void closeState() | 149 | void closeState() |
145 | { | 150 | { |
151 | { | ||
152 | std::lock_guard<std::mutex> _guard{ debugNameMutex }; | ||
153 | debugName = std::string_view{ "<gc>" }; | ||
154 | } | ||
146 | lua_State* _L{ S }; | 155 | lua_State* _L{ S }; |
147 | S = nullptr; | 156 | S = nullptr; |
148 | L = nullptr; | 157 | L = nullptr; |
149 | lua_close(_L); // this collects our coroutine thread at the same time | 158 | lua_close(_L); // this collects our coroutine thread at the same time |
150 | } | 159 | } |
151 | [[nodiscard]] std::string_view errorTraceLevelString() const; | 160 | [[nodiscard]] std::string_view errorTraceLevelString() const; |
161 | [[nodiscard]] std::string_view getDebugName() const | ||
162 | { | ||
163 | std::lock_guard<std::mutex> _guard{ debugNameMutex }; | ||
164 | return debugName; | ||
165 | } | ||
152 | [[nodiscard]] int pushErrorHandler() const; | 166 | [[nodiscard]] int pushErrorHandler() const; |
153 | [[nodiscard]] std::string_view pushErrorTraceLevel(lua_State* L_) const; | 167 | [[nodiscard]] std::string_view pushErrorTraceLevel(lua_State* L_) const; |
154 | static void PushMetatable(lua_State* L_); | 168 | static void PushMetatable(lua_State* L_); |