From 6b85fa5611046d139d8e5f584c8ea4e7eb14f346 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Thu, 8 May 2025 13:26:08 -0700 Subject: [PATCH] SignalScopeGuards: Review --- .../include/FEXCore/Utils/SignalScopeGuards.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/FEXCore/include/FEXCore/Utils/SignalScopeGuards.h b/FEXCore/include/FEXCore/Utils/SignalScopeGuards.h index 159e3a118..0ab8cf140 100644 --- a/FEXCore/include/FEXCore/Utils/SignalScopeGuards.h +++ b/FEXCore/include/FEXCore/Utils/SignalScopeGuards.h @@ -45,12 +45,10 @@ public: Mutex = PTHREAD_MUTEX_INITIALIZER; } - // Checks and asserts if the mutex isn't owned by the calling thread. + // Asserts that the mutex isn't exclusively owned by the calling thread. void check_lock_owned_by_self() { - const auto Result = pthread_mutex_lock(&Mutex); - if (Result == 0) [[unlikely]] { - ERROR_AND_DIE_FMT("User of unique lock must have already locked mutex as write!"); - } + [[maybe_unused]] const auto Result = pthread_mutex_lock(&Mutex); + LOGMAN_THROW_A_FMT(Result == EDEADLK, "User of unique lock must have already locked mutex as write!"); } private: @@ -95,12 +93,10 @@ public: return Result == 0; } - // Checks and asserts if the rwlock isn't owned by the calling thread with write semantics. + // Asserts that the rwlock isn't exclusively owned by the calling thread. void check_lock_owned_by_self_as_write() { - const auto Result = pthread_rwlock_wrlock(&Mutex); - if (Result == 0) [[unlikely]] { - ERROR_AND_DIE_FMT("User of rwlock must have already locked mutex as write!"); - } + [[maybe_unused]] const auto Result = pthread_rwlock_wrlock(&Mutex); + LOGMAN_THROW_A_FMT(Result == EDEADLK, "User of rwlock must have already locked mutex as write!"); } // Initialize the internal pthread object to its default initializer state.