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