SignalScopeGuards: Review

This commit is contained in:
Ryan Houdek committed 2025-05-14 10:56:44 -07:00
1 parent fae66a921f
commit 6b85fa5611
1 file changed
+6 -10
@@ -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.