diff --git a/Source/Threading/Primitives/AuWoASemaphore.Unix.cpp b/Source/Threading/Primitives/AuWoASemaphore.Unix.cpp index 752c1c42..eba1f77e 100644 --- a/Source/Threading/Primitives/AuWoASemaphore.Unix.cpp +++ b/Source/Threading/Primitives/AuWoASemaphore.Unix.cpp @@ -152,7 +152,7 @@ namespace Aurora::Threading::Primitives WoASemaphoreImpl::~WoASemaphoreImpl() { - ::pthread_cond_destroy(&this->pthreadCv_); + } bool WoASemaphoreImpl::HasOSHandle(AuMach &mach) @@ -182,6 +182,7 @@ namespace Aurora::Threading::Primitives { while (!this->TryLock()) { + AU_LOCK_GUARD(this->mutex_); (void)this->cond_.WaitForSignalNsEx(&this->mutex_, 0, true); } @@ -194,7 +195,11 @@ namespace Aurora::Threading::Primitives return true; } - (void)this->cond_.WaitForSignalNsEx(&this->mutex_, uTimeout, true); + { + AU_LOCK_GUARD(this->mutex_); + (void)this->cond_.WaitForSignalNsEx(&this->mutex_, uTimeout, true); + } + return this->TryLock(); } }