diff --git a/Source/Threading/Primitives/AuMutex.Linux.cpp b/Source/Threading/Primitives/AuMutex.Linux.cpp index a4cdd126..dfd9ce2b 100755 --- a/Source/Threading/Primitives/AuMutex.Linux.cpp +++ b/Source/Threading/Primitives/AuMutex.Linux.cpp @@ -111,47 +111,32 @@ namespace Aurora::Threading::Primitives do { ret = futex_wait(&this->value_, state, &tspec); - - if (ret == 0) - { - continue; - } - - if (ret == EAGAIN || errno == EAGAIN) - { - continue; - } - - if (ret == ETIMEDOUT || errno == ETIMEDOUT) - { - return false; - } } while (ret == EINTR); - - RUNTIME_ASSERT_SHUTDOWN_SAFE(false, "semaphore timed wait failed: {}", ret) - return false; } else { int ret {}; + bool bStatus {}; + do { if ((ret = futex_wait(&this->value_, state)) == 0) { - continue; + bStatus = true; + break; } if (ret == EAGAIN || errno == EAGAIN) { - continue; + bStatus = true; + break; } } while (ret == EINTR); - RUNTIME_ASSERT_SHUTDOWN_SAFE(false, "semaphore wait failed: {}", ret) - return false; + RUNTIME_ASSERT_SHUTDOWN_SAFE(bStatus, "Mutex wait failed: {}", ret) } state = this->value_; diff --git a/Source/Threading/Primitives/AuMutex.Unix.cpp b/Source/Threading/Primitives/AuMutex.Unix.cpp index e365d592..91ee1dfb 100644 --- a/Source/Threading/Primitives/AuMutex.Unix.cpp +++ b/Source/Threading/Primitives/AuMutex.Unix.cpp @@ -74,6 +74,7 @@ namespace Aurora::Threading::Primitives Time::auabsns2ts(&tspec, uEnd); } + int ret {}; while (!this->TryLock()) { if (uTimeout != 0) @@ -84,41 +85,27 @@ namespace Aurora::Threading::Primitives return false; } - int ret {}; do { ret = ::pthread_cond_timedwait(&this->pthreadCv_, mutex, &tspec); - - if (ret == 0) - { - continue; - } - - if (ret == ETIMEDOUT) - { - return false; - } - } while (ret == EINTR); - - RUNTIME_ASSERT_SHUTDOWN_SAFE(false, "Mutex timed wait failed: {}", ret) - return false; } else { - int ret {}; + bool bStatus {}; + do { if ((ret = ::pthread_cond_wait(&this->pthreadCv_, mutex)) == 0) { - continue; + bStatus = true; + break; } } while (ret == EINTR); - RUNTIME_ASSERT_SHUTDOWN_SAFE(false, "Mutex wait failed: {}", ret) - return false; + RUNTIME_ASSERT_SHUTDOWN_SAFE(bStatus, "Mutex wait failed: {}", ret) } } diff --git a/Source/Threading/Primitives/AuSemaphore.Linux.cpp b/Source/Threading/Primitives/AuSemaphore.Linux.cpp index 8cd0331e..85e6995a 100644 --- a/Source/Threading/Primitives/AuSemaphore.Linux.cpp +++ b/Source/Threading/Primitives/AuSemaphore.Linux.cpp @@ -102,7 +102,6 @@ namespace Aurora::Threading::Primitives while (!((old != 0) && (AuAtomicCompareExchange(&this->value_, old - 1, old) == old))) { - if (uTimeout != 0) { uStart = Time::SteadyClockNS(); @@ -115,47 +114,32 @@ namespace Aurora::Threading::Primitives do { ret = futex_wait(&this->value_, 0, &tspec); - - if (ret == 0) - { - continue; - } - - if (ret == EAGAIN || errno == EAGAIN) - { - continue; - } - - if (ret == ETIMEDOUT || errno == ETIMEDOUT) - { - return false; - } } while (ret == EINTR); - - RUNTIME_ASSERT_SHUTDOWN_SAFE(false, "semaphore timed wait failed: {}", ret) - return false; } else { int ret {}; + bool bStatus {}; + do { if ((ret = futex_wait(&this->value_, 0)) == 0) { + bStatus = true; continue; } if (ret == EAGAIN || errno == EAGAIN) { + bStatus = true; continue; } } while (ret == EINTR); - RUNTIME_ASSERT_SHUTDOWN_SAFE(false, "semaphore wait failed: {}", ret) - return false; + RUNTIME_ASSERT_SHUTDOWN_SAFE(bStatus, "semaphore wait failed: {}", ret) } old = this->value_; diff --git a/Source/Threading/Primitives/AuSemaphore.Unix.cpp b/Source/Threading/Primitives/AuSemaphore.Unix.cpp index ef7e709b..d040974d 100644 --- a/Source/Threading/Primitives/AuSemaphore.Unix.cpp +++ b/Source/Threading/Primitives/AuSemaphore.Unix.cpp @@ -90,39 +90,26 @@ namespace Aurora::Threading::Primitives do { ret = ::pthread_cond_timedwait(&this->pthreadCv_, mutex, &tspec); - - if (ret == 0) - { - continue; - } - - if (ret == ETIMEDOUT) - { - return false; - } - } while (ret == EINTR); - - RUNTIME_ASSERT_SHUTDOWN_SAFE(false, "semaphore timed wait failed: {}", ret) - return false; } else { int ret {}; + bool bStatus {}; + do { if ((ret = ::pthread_cond_wait(&this->pthreadCv_, mutex)) == 0) { - continue; + bStatus = true; + break; } } while (ret == EINTR); - RUNTIME_ASSERT_SHUTDOWN_SAFE(false, "conditional wait failed: {}", ret) - return false; + RUNTIME_ASSERT_SHUTDOWN_SAFE(bStatus, "semaphore wait failed: {}", ret) } - } return true;