aboutsummaryrefslogtreecommitdiff
path: root/src/lane.cpp
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-11-20 18:03:33 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2024-11-20 18:03:33 +0100
commit0f6f3c207c46fa28059403e5f16af774d20c7ea2 (patch)
tree8031145bb2534c33ca0f2c65b9de85696c8a8ee0 /src/lane.cpp
parent304e4dfabe4555dff4aa72e75b677405fd30d1b3 (diff)
downloadlanes-0f6f3c207c46fa28059403e5f16af774d20c7ea2.tar.gz
lanes-0f6f3c207c46fa28059403e5f16af774d20c7ea2.tar.bz2
lanes-0f6f3c207c46fa28059403e5f16af774d20c7ea2.zip
More [[nodiscard]] boyscouting
Diffstat (limited to 'src/lane.cpp')
-rw-r--r--src/lane.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/lane.cpp b/src/lane.cpp
index 00f857e..923eabd 100644
--- a/src/lane.cpp
+++ b/src/lane.cpp
@@ -484,7 +484,8 @@ int Lane::LuaErrorHandler(lua_State* L_)
484// ########################################## Finalizer ############################################ 484// ########################################## Finalizer ############################################
485// ################################################################################################# 485// #################################################################################################
486 486
487[[nodiscard]] static int PushStackTrace(lua_State* const L_, Lane::ErrorTraceLevel const errorTraceLevel_, LuaError const rc_, [[maybe_unused]] StackIndex const stk_base_) 487[[nodiscard]]
488static int PushStackTrace(lua_State* const L_, Lane::ErrorTraceLevel const errorTraceLevel_, LuaError const rc_, [[maybe_unused]] StackIndex const stk_base_)
488{ 489{
489 // Lua 5.1 error handler is limited to one return value; it stored the stack trace in the registry 490 // Lua 5.1 error handler is limited to one return value; it stored the stack trace in the registry
490 StackIndex const _top{ lua_gettop(L_) }; 491 StackIndex const _top{ lua_gettop(L_) };
@@ -536,7 +537,8 @@ int Lane::LuaErrorHandler(lua_State* L_)
536// TBD: should we add stack trace on failing finalizer, wouldn't be hard.. 537// TBD: should we add stack trace on failing finalizer, wouldn't be hard..
537// 538//
538 539
539[[nodiscard]] static LuaError run_finalizers(Lane* const lane_, Lane::ErrorTraceLevel const errorTraceLevel_, LuaError const lua_rc_) 540[[nodiscard]]
541static LuaError run_finalizers(Lane* const lane_, Lane::ErrorTraceLevel const errorTraceLevel_, LuaError const lua_rc_)
540{ 542{
541 // if we are a coroutine, we can't run the finalizers in the coroutine state! 543 // if we are a coroutine, we can't run the finalizers in the coroutine state!
542 lua_State* const _L{ lane_->S }; 544 lua_State* const _L{ lane_->S };
@@ -641,7 +643,8 @@ void Lane::selfdestructAdd()
641// ################################################################################################# 643// #################################################################################################
642 644
643// A free-running lane has ended; remove it from selfdestruct chain 645// A free-running lane has ended; remove it from selfdestruct chain
644[[nodiscard]] bool Lane::selfdestructRemove() 646[[nodiscard]]
647bool Lane::selfdestructRemove()
645{ 648{
646 bool _found{ false }; 649 bool _found{ false };
647 std::lock_guard<std::mutex> _guard{ U->selfdestructMutex }; 650 std::lock_guard<std::mutex> _guard{ U->selfdestructMutex };
@@ -938,7 +941,8 @@ CancelResult Lane::cancel(CancelOp const op_, std::chrono::time_point<std::chron
938 941
939// ################################################################################################# 942// #################################################################################################
940 943
941[[nodiscard]] CancelResult Lane::internalCancel(CancelRequest const rq_, std::chrono::time_point<std::chrono::steady_clock> const until_, WakeLane const wakeLane_) 944[[nodiscard]]
945CancelResult Lane::internalCancel(CancelRequest const rq_, std::chrono::time_point<std::chrono::steady_clock> const until_, WakeLane const wakeLane_)
942{ 946{
943 cancelRequest.store(rq_, std::memory_order_relaxed); // it's now signaled to stop 947 cancelRequest.store(rq_, std::memory_order_relaxed); // it's now signaled to stop
944 if (rq_ == CancelRequest::Hard) { 948 if (rq_ == CancelRequest::Hard) {
@@ -992,7 +996,8 @@ void Lane::changeDebugName(StackIndex const nameIdx_)
992// / "error" finished at an error, error value is there 996// / "error" finished at an error, error value is there
993// / "cancelled" execution cancelled by M (state gone) 997// / "cancelled" execution cancelled by M (state gone)
994// 998//
995[[nodiscard]] std::string_view Lane::errorTraceLevelString() const 999[[nodiscard]]
1000std::string_view Lane::errorTraceLevelString() const
996{ 1001{
997 std::string_view const _str{ 1002 std::string_view const _str{
998 (errorTraceLevel == ErrorTraceLevel::Minimal) ? "minimal" : 1003 (errorTraceLevel == ErrorTraceLevel::Minimal) ? "minimal" :
@@ -1107,7 +1112,8 @@ void Lane::pushIndexedResult(lua_State* const L_, int const key_) const
1107 1112
1108// ################################################################################################# 1113// #################################################################################################
1109 1114
1110[[nodiscard]] std::string_view Lane::pushErrorTraceLevel(lua_State* L_) const 1115[[nodiscard]]
1116std::string_view Lane::pushErrorTraceLevel(lua_State* L_) const
1111{ 1117{
1112 std::string_view const _str{ errorTraceLevelString() }; 1118 std::string_view const _str{ errorTraceLevelString() };
1113 LUA_ASSERT(L_, !_str.empty()); 1119 LUA_ASSERT(L_, !_str.empty());
@@ -1287,7 +1293,8 @@ int Lane::storeResults(lua_State* const L_)
1287// "error" finished at an error, error value is there 1293// "error" finished at an error, error value is there
1288// "cancelled" execution cancelled (state gone) 1294// "cancelled" execution cancelled (state gone)
1289// 1295//
1290[[nodiscard]] std::string_view Lane::threadStatusString() const 1296[[nodiscard]]
1297std::string_view Lane::threadStatusString() const
1291{ 1298{
1292 static constexpr std::string_view kStrs[] = { 1299 static constexpr std::string_view kStrs[] = {
1293 "pending", 1300 "pending",