[development] removal of unused and low stakes code related to Cry-threading (#2896)
Removal highlights include: - File indexer (used CryThread<>) linked to long gone asset browser - Producer/consumer queues from CryMT - set/vector/CLocklessPointerQueue containers also from CryMT - Cry interlocked linked list and _InterlockedCompareExchange128 - CryThread type - SAtomicVar types - CryAutoSet type - Various unused lock types -- AutoLockModify -- AutoLockRead -- CryOptionalAutoLock -- CryReadModifyLock -- CryRWLock -- ReadLock -- ReadLockCond -- WriteAfterReadLock - Misc. unused functions -- CryInterLockedAdd (not to be confused with CryInterlockedAdd, using a lower case "locked") -- CryInterlockedExchange64 (which was only defined for unix platforms) -- SpinLock -- JobSpinLock -- AtomicAdd -- JobAtomicAdd Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com>
This commit is contained in:
@@ -303,78 +303,6 @@ void CryFastSemaphore::Release()
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CryRWLock::CryRWLock()
|
||||
{
|
||||
STATIC_ASSERT(sizeof(m_Lock) == sizeof(PSRWLOCK), "RWLock-pointer has invalid size");
|
||||
InitializeSRWLock(reinterpret_cast<PSRWLOCK>(&m_Lock));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CryRWLock::~CryRWLock()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CryRWLock::RLock()
|
||||
{
|
||||
AcquireSRWLockShared(reinterpret_cast<PSRWLOCK>(&m_Lock));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#if defined(_CRYTHREAD_WANT_TRY_RWLOCK)
|
||||
bool CryRWLock::TryRLock()
|
||||
{
|
||||
return TryAcquireSRWLockShared(reinterpret_cast<PSRWLOCK>(&m_Lock)) != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CryRWLock::RUnlock()
|
||||
{
|
||||
ReleaseSRWLockShared(reinterpret_cast<PSRWLOCK>(&m_Lock));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CryRWLock::WLock()
|
||||
{
|
||||
AcquireSRWLockExclusive(reinterpret_cast<PSRWLOCK>(&m_Lock));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#if defined(_CRYTHREAD_WANT_TRY_RWLOCK)
|
||||
bool CryRWLock::TryWLock()
|
||||
{
|
||||
return TryAcquireSRWLockExclusive(reinterpret_cast<PSRWLOCK>(&m_Lock)) != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CryRWLock::WUnlock()
|
||||
{
|
||||
ReleaseSRWLockExclusive(reinterpret_cast<PSRWLOCK>(&m_Lock));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CryRWLock::Lock()
|
||||
{
|
||||
WLock();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#if defined(_CRYTHREAD_WANT_TRY_RWLOCK)
|
||||
bool CryRWLock::TryLock()
|
||||
{
|
||||
return TryWLock();
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CryRWLock::Unlock()
|
||||
{
|
||||
WUnlock();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CrySimpleThreadSelf::CrySimpleThreadSelf()
|
||||
: m_thread(NULL)
|
||||
@@ -415,181 +343,3 @@ void CrySimpleThreadSelf::StartThread(unsigned (__stdcall * func)(void*), void*
|
||||
PREFAST_ASSUME(m_thread);
|
||||
ResumeThread((HANDLE)m_thread);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CryInterlockedPushEntrySList(SLockFreeSingleLinkedListHeader& list, SLockFreeSingleLinkedListEntry& element)
|
||||
{
|
||||
STATIC_CHECK(sizeof(SLockFreeSingleLinkedListHeader) == sizeof(SLIST_HEADER), CRY_INTERLOCKED_SLIST_HEADER_HAS_WRONG_SIZE);
|
||||
STATIC_CHECK(sizeof(SLockFreeSingleLinkedListEntry) >= sizeof(SLIST_ENTRY), CRY_INTERLOCKED_SLIST_ENTRY_HAS_WRONG_SIZE);
|
||||
|
||||
assert(IsAligned(&list, MEMORY_ALLOCATION_ALIGNMENT) && "LockFree SingleLink List Header has wrong Alignment");
|
||||
assert(IsAligned(&element, MEMORY_ALLOCATION_ALIGNMENT) && "LockFree SingleLink List Entry has wrong Alignment");
|
||||
InterlockedPushEntrySList(alias_cast<PSLIST_HEADER>(&list), alias_cast<PSLIST_ENTRY>(&element));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void* CryInterlockedPopEntrySList(SLockFreeSingleLinkedListHeader& list)
|
||||
{
|
||||
STATIC_CHECK(sizeof(SLockFreeSingleLinkedListHeader) == sizeof(SLIST_HEADER), CRY_INTERLOCKED_SLIST_HEADER_HAS_WRONG_SIZE);
|
||||
|
||||
assert(IsAligned(&list, MEMORY_ALLOCATION_ALIGNMENT) && "LockFree SingleLink List Header has wrong Alignment");
|
||||
return reinterpret_cast<void*>(InterlockedPopEntrySList(alias_cast<PSLIST_HEADER>(&list)));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CryInitializeSListHead(SLockFreeSingleLinkedListHeader& list)
|
||||
{
|
||||
assert(IsAligned(&list, MEMORY_ALLOCATION_ALIGNMENT) && "LockFree SingleLink List Header has wrong Alignment");
|
||||
|
||||
STATIC_CHECK(sizeof(SLockFreeSingleLinkedListHeader) == sizeof(SLIST_HEADER), CRY_INTERLOCKED_SLIST_HEADER_HAS_WRONG_SIZE);
|
||||
InitializeSListHead(alias_cast<PSLIST_HEADER>(&list));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void* CryInterlockedFlushSList(SLockFreeSingleLinkedListHeader& list)
|
||||
{
|
||||
assert(IsAligned(&list, MEMORY_ALLOCATION_ALIGNMENT) && "LockFree SingleLink List Header has wrong Alignment");
|
||||
|
||||
STATIC_CHECK(sizeof(SLockFreeSingleLinkedListHeader) == sizeof(SLIST_HEADER), CRY_INTERLOCKED_SLIST_HEADER_HAS_WRONG_SIZE);
|
||||
return InterlockedFlushSList(alias_cast<PSLIST_HEADER>(&list));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// base class for lock less Producer/Consumer queue, due platforms specific they
|
||||
// are implemeted in CryThead_platform.h
|
||||
namespace CryMT {
|
||||
namespace detail {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void SingleProducerSingleConsumerQueueBase::Push(void* pObj, volatile uint32& rProducerIndex, volatile uint32& rComsumerIndex, uint32 nBufferSize, void* arrBuffer, uint32 nObjectSize)
|
||||
{
|
||||
// spin if queue is full
|
||||
int iter = 0;
|
||||
while (rProducerIndex - rComsumerIndex == nBufferSize)
|
||||
{
|
||||
CryLowLatencySleep(iter++ > 10 ? 1 : 0);
|
||||
}
|
||||
|
||||
MemoryBarrier();
|
||||
char* pBuffer = alias_cast<char*>(arrBuffer);
|
||||
uint32 nIndex = rProducerIndex % nBufferSize;
|
||||
|
||||
memcpy(pBuffer + (nIndex * nObjectSize), pObj, nObjectSize);
|
||||
MemoryBarrier();
|
||||
rProducerIndex += 1;
|
||||
MemoryBarrier();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void SingleProducerSingleConsumerQueueBase::Pop(void* pObj, volatile uint32& rProducerIndex, volatile uint32& rComsumerIndex, uint32 nBufferSize, void* arrBuffer, uint32 nObjectSize)
|
||||
{
|
||||
MemoryBarrier();
|
||||
// busy-loop if queue is empty
|
||||
int iter = 0;
|
||||
while (rProducerIndex - rComsumerIndex == 0)
|
||||
{
|
||||
CryLowLatencySleep(iter++ > 10 ? 1 : 0);
|
||||
}
|
||||
|
||||
char* pBuffer = alias_cast<char*>(arrBuffer);
|
||||
uint32 nIndex = rComsumerIndex % nBufferSize;
|
||||
|
||||
memcpy(pObj, pBuffer + (nIndex * nObjectSize), nObjectSize);
|
||||
MemoryBarrier();
|
||||
rComsumerIndex += 1;
|
||||
MemoryBarrier();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void N_ProducerSingleConsumerQueueBase::Push(void* pObj, volatile uint32& rProducerIndex, volatile uint32& rComsumerIndex, [[maybe_unused]] volatile uint32& rRunning, void* arrBuffer, uint32 nBufferSize, uint32 nObjectSize, volatile uint32* arrStates)
|
||||
{
|
||||
MemoryBarrier();
|
||||
uint32 nProducerIndex;
|
||||
uint32 nComsumerIndex;
|
||||
|
||||
int iter = 0;
|
||||
do
|
||||
{
|
||||
nProducerIndex = rProducerIndex;
|
||||
nComsumerIndex = rComsumerIndex;
|
||||
|
||||
if (nProducerIndex - nComsumerIndex == nBufferSize)
|
||||
{
|
||||
CryLowLatencySleep(iter++ > 10 ? 1 : 0);
|
||||
if (iter > 20) // 10 spins + 10 ms wait
|
||||
{
|
||||
uint32 nSizeToAlloc = sizeof(SFallbackList) + nObjectSize - 1;
|
||||
SFallbackList* pFallbackEntry = (SFallbackList*)CryModuleMemalign(nSizeToAlloc, 128);
|
||||
memcpy(pFallbackEntry->object, pObj, nObjectSize);
|
||||
MemoryBarrier();
|
||||
CryInterlockedPushEntrySList(fallbackList, pFallbackEntry->nextEntry);
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CryInterlockedCompareExchange(alias_cast<volatile LONG*>(&rProducerIndex), nProducerIndex + 1, nProducerIndex) == nProducerIndex)
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
|
||||
MemoryBarrier();
|
||||
char* pBuffer = alias_cast<char*>(arrBuffer);
|
||||
uint32 nIndex = nProducerIndex % nBufferSize;
|
||||
|
||||
memcpy(pBuffer + (nIndex * nObjectSize), pObj, nObjectSize);
|
||||
MemoryBarrier();
|
||||
arrStates[nIndex] = 1;
|
||||
MemoryBarrier();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
bool N_ProducerSingleConsumerQueueBase::Pop(void* pObj, volatile uint32& rProducerIndex, volatile uint32& rComsumerIndex, volatile uint32& rRunning, void* arrBuffer, uint32 nBufferSize, uint32 nObjectSize, volatile uint32* arrStates)
|
||||
{
|
||||
MemoryBarrier();
|
||||
|
||||
// busy-loop if queue is empty
|
||||
int iter = 0;
|
||||
if (rRunning && rProducerIndex - rComsumerIndex == 0)
|
||||
{
|
||||
while (rRunning && rProducerIndex - rComsumerIndex == 0)
|
||||
{
|
||||
CryLowLatencySleep(iter++ > 10 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (rRunning == 0 && rProducerIndex - rComsumerIndex == 0)
|
||||
{
|
||||
SFallbackList* pFallback = (SFallbackList*)CryInterlockedPopEntrySList(fallbackList);
|
||||
IF (pFallback, 0)
|
||||
{
|
||||
memcpy(pObj, pFallback->object, nObjectSize);
|
||||
CryModuleMemalignFree(pFallback);
|
||||
return true;
|
||||
}
|
||||
// if the queue was empty, make sure we really are empty
|
||||
return false;
|
||||
}
|
||||
|
||||
iter = 0;
|
||||
while (arrStates[rComsumerIndex % nBufferSize] == 0)
|
||||
{
|
||||
CryLowLatencySleep(iter++ > 10 ? 1 : 0);
|
||||
}
|
||||
|
||||
char* pBuffer = alias_cast<char*>(arrBuffer);
|
||||
uint32 nIndex = rComsumerIndex % nBufferSize;
|
||||
|
||||
memcpy(pObj, pBuffer + (nIndex * nObjectSize), nObjectSize);
|
||||
MemoryBarrier();
|
||||
arrStates[nIndex] = 0;
|
||||
MemoryBarrier();
|
||||
rComsumerIndex += 1;
|
||||
MemoryBarrier();
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace CryMT
|
||||
|
||||
Reference in New Issue
Block a user