[+] WOA_SEMAPHORE_MODE
This commit is contained in:
parent
3f43c320c5
commit
1a71a7dd41
@ -81,7 +81,9 @@ namespace Aurora::Threading
|
||||
|
||||
bool WaitEntry::SleepOn(WaitState &state)
|
||||
{
|
||||
#if !defined(WOA_SEMAPHORE_MODE)
|
||||
AU_LOCK_GUARD(this->mutex);
|
||||
#endif
|
||||
|
||||
if (state.qwNanosecondsAbs)
|
||||
{
|
||||
@ -100,8 +102,6 @@ namespace Aurora::Threading
|
||||
return true;
|
||||
}
|
||||
|
||||
auto uTimeRemNS = uEndTime - uNow;
|
||||
|
||||
#if defined(AURORA_PLATFORM_WIN32)
|
||||
Win32DropSchedulerResolution();
|
||||
#endif
|
||||
@ -112,7 +112,12 @@ namespace Aurora::Threading
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(WOA_SEMAPHORE_MODE)
|
||||
this->semaphore->LockAbsNS(uEndTime);
|
||||
#else
|
||||
auto uTimeRemNS = uEndTime - uNow;
|
||||
this->variable.WaitForSignalNsEx(&this->mutex, uTimeRemNS);
|
||||
#endif
|
||||
}
|
||||
|
||||
uNow = AuTime::SteadyClockNS();
|
||||
@ -130,7 +135,11 @@ namespace Aurora::Threading
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(WOA_SEMAPHORE_MODE)
|
||||
this->semaphore->Lock();
|
||||
#else
|
||||
this->variable.WaitForSignalNsEx(&this->mutex, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,7 +156,11 @@ namespace Aurora::Threading
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(WOA_SEMAPHORE_MODE)
|
||||
this->semaphore->Unlock(1);
|
||||
#else
|
||||
this->variable.Signal();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -262,10 +275,12 @@ namespace Aurora::Threading
|
||||
decltype(pCurrentHead) pLast {};
|
||||
while (pCurrentHead)
|
||||
{
|
||||
#if !defined(WOA_SEMAPHORE_MODE)
|
||||
// Insertion barrier
|
||||
{
|
||||
AU_LOCK_GUARD(pCurrentHead->mutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
auto [bCont, bRemove] = callback(*pCurrentHead);
|
||||
|
||||
|
@ -47,8 +47,19 @@ namespace Aurora::Threading
|
||||
WaitEntry *pBefore {};
|
||||
|
||||
// synch
|
||||
#if defined(WOA_SEMAPHORE_MODE)
|
||||
#if defined(WOA_SEMAPHORE_SEMAPHORE)
|
||||
// PORT: MacOS (?)
|
||||
WOA_SEMAPHORE_SEMAPHORE semaphore;
|
||||
#else
|
||||
// Testing:
|
||||
Primitives::Semaphore semaphore;
|
||||
#endif
|
||||
#else
|
||||
// Recommended (we can better filter spurious wakes for the cost of a barrier on signal):
|
||||
Primitives::ConditionMutexInternal mutex; // mutex ctor must come before var
|
||||
Primitives::ConditionVariableInternal variable; // ...and something all 2007+ micro and monolithic kernels should have to yield for an event
|
||||
#endif
|
||||
|
||||
// state
|
||||
const void *pAddress {};
|
||||
|
Loading…
Reference in New Issue
Block a user