aboutsummaryrefslogtreecommitdiff
path: root/src/lane.h
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-07-04 08:49:45 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-07-04 08:49:45 +0200
commitacb1fa879beb68c10287b8438f18b80b2700042f (patch)
tree8216583d51e7e358e0eeafd7b37fbb55ae8bcea4 /src/lane.h
parent0880a486b0f3bb289ec160fc8e199e126e4f45a0 (diff)
downloadlanes-acb1fa879beb68c10287b8438f18b80b2700042f.tar.gz
lanes-acb1fa879beb68c10287b8438f18b80b2700042f.tar.bz2
lanes-acb1fa879beb68c10287b8438f18b80b2700042f.zip
Error handling in coroutine lanes
Diffstat (limited to 'src/lane.h')
-rw-r--r--src/lane.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lane.h b/src/lane.h
index 6dccd3a..f0fd0ac 100644
--- a/src/lane.h
+++ b/src/lane.h
@@ -158,12 +158,19 @@ class Lane
158 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
159 } 159 }
160 [[nodiscard]] std::string_view errorTraceLevelString() const; 160 [[nodiscard]] std::string_view errorTraceLevelString() const;
161 [[nodiscard]] int errorHandlerCount() const noexcept
162 {
163 // don't push a error handler when in coroutine mode, as the first lua_resume wants only the function and its arguments on the stack
164 return ((errorTraceLevel == Lane::Minimal) || isCoroutine()) ? 0 : 1;
165 }
166 [[nodiscard]] bool isCoroutine() const noexcept { return S != L; }
161 [[nodiscard]] std::string_view getDebugName() const 167 [[nodiscard]] std::string_view getDebugName() const
162 { 168 {
163 std::lock_guard<std::mutex> _guard{ debugNameMutex }; 169 std::lock_guard<std::mutex> _guard{ debugNameMutex };
164 return debugName; 170 return debugName;
165 } 171 }
166 [[nodiscard]] int pushErrorHandler() const; 172 static int LuaErrorHandler(lua_State* L_);
173 [[nodiscard]] int pushErrorHandler() const noexcept { return (errorHandlerCount() == 0) ? 0 : (lua_pushcfunction(L, LuaErrorHandler), 1); }
167 [[nodiscard]] std::string_view pushErrorTraceLevel(lua_State* L_) const; 174 [[nodiscard]] std::string_view pushErrorTraceLevel(lua_State* L_) const;
168 static void PushMetatable(lua_State* L_); 175 static void PushMetatable(lua_State* L_);
169 void pushStatusString(lua_State* L_) const; 176 void pushStatusString(lua_State* L_) const;