[-] Remove unused code from WakeOnAddress
This commit is contained in:
parent
99e8c68c62
commit
e2758ea243
@ -8,9 +8,11 @@
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "AuWakeOnAddress.hpp"
|
||||
#include "Primitives/SMTYield.hpp"
|
||||
|
||||
#if defined(AURORA_PLATFORM_WIN32)
|
||||
#include <timeapi.h>
|
||||
#endif
|
||||
|
||||
#include <Time/Time.hpp>
|
||||
|
||||
#define HACK_NO_INVALID_ACCESS_LEAK_SHARED_REF_ON_DESTROYED_THREAD
|
||||
@ -104,14 +106,6 @@ namespace Aurora::Threading
|
||||
|
||||
void WaitEntry::Release()
|
||||
{
|
||||
#if 0
|
||||
if (this->bOverflow)
|
||||
{
|
||||
gProcessWaitables.Remove(this);
|
||||
this->bOverflow = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
AuResetMember(this->uSize);
|
||||
AuResetMember(this->pAddress);
|
||||
}
|
||||
@ -287,16 +281,6 @@ namespace Aurora::Threading
|
||||
|
||||
WaitEntry *ProcessWaitContainer::WaitBufferFrom(void *pAddress, AuUInt8 uSize)
|
||||
{
|
||||
#if defined(WOA_ENABLE_OLD_SHORT_LIST)
|
||||
for (AU_ITERATE_N(i, kDefaultWaitPerProcess))
|
||||
{
|
||||
if (this->entries[i].TryAcquire(pAddress, uSize))
|
||||
{
|
||||
return &this->entries[i];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HACK_NO_INVALID_ACCESS_LEAK_SHARED_REF_ON_DESTROYED_THREAD)
|
||||
auto pReturn = tlsWaitEntry.get();
|
||||
#else
|
||||
@ -327,118 +311,6 @@ namespace Aurora::Threading
|
||||
return pReturn;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool ProcessWaitContainer::IterateAll(T callback)
|
||||
{
|
||||
#if defined(WOA_ENABLE_OLD_SHORT_LIST)
|
||||
for (AU_ITERATE_N(i, kDefaultWaitPerProcess))
|
||||
{
|
||||
auto &entry = this->entries[i];
|
||||
{
|
||||
DoSpinLockOnVar(&entry.uAtomic);
|
||||
|
||||
if (entry.pAddress)
|
||||
{
|
||||
// Intentional lock/unlock order:
|
||||
AU_LOCK_GUARD(entry.mutex);
|
||||
entry.uAtomic = 0;
|
||||
|
||||
if (!callback(entry))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.uAtomic = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
Lock();
|
||||
auto pCurrentHead = this->waitList.pHead;
|
||||
while (pCurrentHead)
|
||||
{
|
||||
AU_LOCK_GUARD(pCurrentHead->mutex);
|
||||
|
||||
if (!callback(pCurrentHead))
|
||||
{
|
||||
Unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
pCurrentHead = pCurrentHead->pNext;
|
||||
}
|
||||
Unlock();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool ProcessWaitContainer::IterateForceNoCreateDuringOp(T callback)
|
||||
{
|
||||
bool bRetStatus { true };
|
||||
|
||||
#if defined(WOA_ENABLE_OLD_SHORT_LIST)
|
||||
for (AU_ITERATE_N(i, kDefaultWaitPerProcess))
|
||||
{
|
||||
auto &entry = this->entries[i];
|
||||
{
|
||||
DoSpinLockOnVar(&entry.uAtomic);
|
||||
|
||||
if (entry.pAddress)
|
||||
{
|
||||
AU_LOCK_GUARD(entry.mutex);
|
||||
if (!callback(entry))
|
||||
{
|
||||
for (AU_ITERATE_N(z, i + 1))
|
||||
{
|
||||
this->entries[z].uAtomic = 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
Lock();
|
||||
auto pCurrentHead = this->waitList.pHead;
|
||||
while (pCurrentHead)
|
||||
{
|
||||
AU_LOCK_GUARD(pCurrentHead->mutex);
|
||||
|
||||
if (!callback(*pCurrentHead))
|
||||
{
|
||||
bRetStatus = false;
|
||||
break;
|
||||
}
|
||||
|
||||
pCurrentHead = pCurrentHead->pNext;
|
||||
}
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
#if defined(WOA_ENABLE_OLD_SHORT_LIST)
|
||||
for (AU_ITERATE_N(i, kDefaultWaitPerProcess))
|
||||
{
|
||||
auto &entry = this->entries[i];
|
||||
{
|
||||
entry.uAtomic = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return bRetStatus;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool ProcessWaitContainer::IterateWake(T callback)
|
||||
{
|
||||
@ -490,42 +362,6 @@ namespace Aurora::Threading
|
||||
}
|
||||
Unlock();
|
||||
|
||||
// meh - just so i can experiment with changes
|
||||
#if defined(WOA_ENABLE_OLD_SHORT_LIST)
|
||||
for (AU_ITERATE_N(i, kDefaultWaitPerProcess))
|
||||
{
|
||||
auto &entry = this->entries[i];
|
||||
{
|
||||
DoSpinLockOnVar(&entry.uAtomic);
|
||||
|
||||
if (entry.pAddress)
|
||||
{
|
||||
AU_LOCK_GUARD(entry.mutex);
|
||||
|
||||
auto [bCont, bRemove] = callback(*entry);
|
||||
|
||||
if (!bCont)
|
||||
{
|
||||
for (AU_ITERATE_N(z, i + 1))
|
||||
{
|
||||
this->entries[z].uAtomic = 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (AU_ITERATE_N(i, kDefaultWaitPerProcess))
|
||||
{
|
||||
auto &entry = this->entries[i];
|
||||
{
|
||||
entry.uAtomic = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return bRetStatus;
|
||||
}
|
||||
|
||||
@ -629,10 +465,6 @@ namespace Aurora::Threading
|
||||
|
||||
auto bResult = pWaitEntry->SleepOn(state);
|
||||
|
||||
#if defined(WOA_USE_DEFERRED_REL)
|
||||
pWaitEntry->Release();
|
||||
#endif
|
||||
|
||||
#if defined(HACK_NO_INVALID_ACCESS_LEAK_SHARED_REF_ON_DESTROYED_THREAD)
|
||||
pTempHoldMe.reset();
|
||||
#endif
|
||||
@ -1058,19 +890,11 @@ namespace Aurora::Threading
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(WOA_USE_DEFERRED_REL)
|
||||
(void)gProcessWaitables.IterateForceNoCreateDuringOp([&](WaitEntry &entry) -> bool
|
||||
#else
|
||||
(void)gProcessWaitables.IterateWake([&](WaitEntry &entry) -> AuPair<bool, bool>
|
||||
#endif
|
||||
{
|
||||
if (!uNMaximumThreads)
|
||||
{
|
||||
#if defined(WOA_USE_DEFERRED_REL)
|
||||
return false;
|
||||
#else
|
||||
return AuMakePair(false, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool bWake {};
|
||||
@ -1081,11 +905,7 @@ namespace Aurora::Threading
|
||||
}
|
||||
|
||||
bool bCont = uNMaximumThreads != 0;
|
||||
#if defined(WOA_USE_DEFERRED_REL)
|
||||
return bCont;
|
||||
#else
|
||||
return AuMakePair(bCont, bWake);
|
||||
#endif
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1103,18 +923,9 @@ namespace Aurora::Threading
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(WOA_USE_DEFERRED_REL)
|
||||
(void)gProcessWaitables.IterateForceNoCreateDuringOp([&](WaitEntry &entry) -> bool
|
||||
#else
|
||||
(void)gProcessWaitables.IterateWake([&](WaitEntry &entry) -> AuPair<bool, bool>
|
||||
#endif
|
||||
{
|
||||
#if defined(WOA_USE_DEFERRED_REL)
|
||||
entry.TryWakeNoLockNoReallyNoLock(pTargetAddress);
|
||||
return true;
|
||||
#else
|
||||
return AuMakePair(true, entry.TryWakeNoLockNoReallyNoLock(pTargetAddress));
|
||||
#endif
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1160,16 +971,4 @@ namespace Aurora::Threading
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Future (Reece): AuThread aware (safe force-terminate)
|
||||
// There are three ways we can go about this:
|
||||
// Shared pointers
|
||||
// Shared pointers such that we dont need to remove the raw pointer optimization
|
||||
// Callback on thread death
|
||||
//
|
||||
// 1st would increase overhead for a case i dont want to condone
|
||||
// 2nd would work but would probably require a callback on death
|
||||
// 3rd would work.
|
||||
//
|
||||
// to be addressed later
|
||||
}
|
@ -81,12 +81,6 @@ namespace Aurora::Threading
|
||||
|
||||
WaitEntry *WaitBufferFrom(void *pAddress, AuUInt8 uSize);
|
||||
|
||||
template <typename T>
|
||||
bool IterateAll(T callback);
|
||||
|
||||
template <typename T>
|
||||
bool IterateForceNoCreateDuringOp(T callback);
|
||||
|
||||
template <typename T>
|
||||
bool IterateWake(T callback);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user