diff --git a/Source/IO/Loop/LSLocalEvent.cpp b/Source/IO/Loop/LSLocalEvent.cpp index 9811883e..aff8e4db 100644 --- a/Source/IO/Loop/LSLocalEvent.cpp +++ b/Source/IO/Loop/LSLocalEvent.cpp @@ -57,6 +57,7 @@ namespace Aurora::IO::Loop } else { + (void)LSSemaphore::OnTrigger(0); return false; } } @@ -69,6 +70,7 @@ namespace Aurora::IO::Loop } else { + (void)LSSemaphore::OnTrigger(0); return false; } } diff --git a/Source/IO/Loop/LSLocalMutex.cpp b/Source/IO/Loop/LSLocalMutex.cpp index fbcc683b..d6403d5d 100644 --- a/Source/IO/Loop/LSLocalMutex.cpp +++ b/Source/IO/Loop/LSLocalMutex.cpp @@ -37,6 +37,7 @@ namespace Aurora::IO::Loop { if (AuAtomicLoad(&this->uAtomicWord) & kFutexBitWake) { + (void)LSSemaphore::OnTrigger(0); AuAtomicSub(&this->uAtomicWord, kFutexBitWake); } diff --git a/Source/IO/Loop/LSLocalSemaphore.cpp b/Source/IO/Loop/LSLocalSemaphore.cpp index 70d96fd0..ebf68253 100644 --- a/Source/IO/Loop/LSLocalSemaphore.cpp +++ b/Source/IO/Loop/LSLocalSemaphore.cpp @@ -37,6 +37,7 @@ namespace Aurora::IO::Loop bool LSLocalSemaphore::OnTrigger(AuUInt handle) { auto bRet = this->TryTakeNoSpin(); + bool bTriggerLater = !bRet; while (true) { @@ -51,17 +52,36 @@ namespace Aurora::IO::Loop { auto uCount = AuAtomicLoad(&this->uAtomicSemaphore); - if (uOld - 1 == 0 && - uCount) + if (uOld - 1 == 0) { - AuAtomicAdd(&this->uAtomicKernelSemaphore, uCount); - LSSemaphore::AddMany(uCount); + if (uCount) + { + AuAtomicAdd(&this->uAtomicKernelSemaphore, uCount); + LSSemaphore::AddMany(uCount); + } + else + { + (void)LSSemaphore::OnTrigger(0); + bTriggerLater = false; + } + } + else if (uOld || !bRet) + { + (void)LSSemaphore::OnTrigger(0); + bTriggerLater = false; } break; } } + #if 0 + if (bTriggerLater) + { + (void)LSSemaphore::OnTrigger(0); + } + #endif + return bRet; }