AuroraRuntime/Source/Threading/Primitives/AuRWLock.cpp

903 lines
24 KiB
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021-2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
2021-06-27 21:25:29 +00:00
2022-11-17 07:46:07 +00:00
File: AuRWLock.cpp
2021-06-27 21:25:29 +00:00
Date: 2021-6-12
Author: Reece
***/
2021-09-30 14:57:41 +00:00
#include <Source/RuntimeInternal.hpp>
//#define RWLOCK_VIEW_HAS_PARENT
2022-11-17 07:46:07 +00:00
#include "AuRWLock.hpp"
#include "SMTYield.hpp"
#include "../AuWakeInternal.hpp"
2021-06-27 21:25:29 +00:00
namespace Aurora::Threading::Primitives
{
#if defined(RWLOCK_VIEW_HAS_PARENT)
#define ViewParent (&this->parent_)
#else
#define ViewParent ((T *)(((char *)this) - (bIsReadView ? RWLockImpl<true>::kOffsetOfRead : RWLockImpl<true>::kOffsetOfWrite)))
#endif
2023-09-19 16:08:06 +00:00
#define RWLockAcquire AU_LOCK_GUARD(this->mutex_);
#define RWLockBarrier(expMutex) { (expMutex).Lock(); (expMutex).Unlock(); }
#define RWLockBarrierSelf() RWLockBarrier(this->mutex_)
2023-07-30 10:10:08 +00:00
static const auto kRWThreadWriterHardContextSwitchBias = 15;
template<bool bIsReadView, typename T>
void RWLockAccessView<bIsReadView, T>::Unlock()
{
if constexpr (bIsReadView)
{
ViewParent->UnlockRead();
}
else
{
ViewParent->UnlockWrite();
}
}
template<bool bIsReadView, typename T>
bool RWLockAccessView<bIsReadView, T>::LockAbsMS(AuUInt64 timeout)
{
if constexpr (bIsReadView)
{
return ViewParent->LockReadNSAbs(AuMSToNS<AuUInt64>(timeout));
}
else
{
return ViewParent->LockWriteNSAbs(AuMSToNS<AuUInt64>(timeout));
}
}
template<bool bIsReadView, typename T>
bool RWLockAccessView<bIsReadView, T>::LockAbsNS(AuUInt64 timeout)
{
if constexpr (bIsReadView)
{
return ViewParent->LockReadNSAbs(timeout);
}
else
{
return ViewParent->LockWriteNSAbs(timeout);
}
}
template<bool bIsReadView, typename T>
bool RWLockAccessView<bIsReadView, T>::LockMS(AuUInt64 timeout)
{
if constexpr (bIsReadView)
{
return ViewParent->LockReadNS(AuMSToNS<AuUInt64>(timeout));
}
else
{
return ViewParent->LockWriteNS(AuMSToNS<AuUInt64>(timeout));
}
}
template<bool bIsReadView, typename T>
bool RWLockAccessView<bIsReadView, T>::LockNS(AuUInt64 timeout)
{
if constexpr (bIsReadView)
{
return ViewParent->LockReadNS(timeout);
}
else
{
return ViewParent->LockWriteNS(timeout);
}
}
template<bool bIsReadView, typename T>
bool RWLockAccessView<bIsReadView, T>::TryLock()
{
if constexpr (bIsReadView)
{
return ViewParent->TryLockRead();
}
else
{
2023-09-19 16:08:06 +00:00
return ViewParent->TryLockWriteMaybeSpin();
}
}
template<bool bIsWriteRecursionAllowed>
RWLockImpl<bIsWriteRecursionAllowed>::RWLockImpl()
#if defined(RWLOCK_VIEW_HAS_PARENT)
: read_(*this),
write_(*this)
#endif
#if 0
, condition_(AuUnsafeRaiiToShared(&this->mutex_)),
conditionWriter_(AuUnsafeRaiiToShared(&this->mutex_))
#endif
2021-06-27 21:25:29 +00:00
{
}
template<bool bIsWriteRecursionAllowed>
RWLockImpl<bIsWriteRecursionAllowed>::~RWLockImpl()
2021-06-27 21:25:29 +00:00
{
}
template<bool bIsWriteRecursionAllowed>
2023-08-21 16:34:24 +00:00
ConditionVariableInternal &RWLockImpl<bIsWriteRecursionAllowed>::GetCondition()
{
#if !defined(AURWLOCK_NO_SIZE_OPTIMIZED_CONDVAR)
2023-08-21 16:34:24 +00:00
return *(ConditionVariableInternal *)this->conditionVariable_;
#else
return this->condition_;
#endif
}
template<bool bIsWriteRecursionAllowed>
2023-08-21 16:34:24 +00:00
ConditionVariableInternal &RWLockImpl<bIsWriteRecursionAllowed>::GetConditionWriter()
{
#if !defined(AURWLOCK_NO_SIZE_OPTIMIZED_CONDVAR)
2023-08-21 16:34:24 +00:00
return *(ConditionVariableInternal *)this->conditionVariableWriter_;
#else
return this->conditionWriter_;
#endif
}
template<bool bIsWriteRecursionAllowed>
AuUInt32 *RWLockImpl<bIsWriteRecursionAllowed>::GetFutexCondition()
{
2023-09-19 16:08:06 +00:00
return (AuUInt32 *)&this->iState_;
}
template<bool bIsWriteRecursionAllowed>
AuUInt32 *RWLockImpl<bIsWriteRecursionAllowed>::GetFutexConditionWriter()
{
return (AuUInt32 *)this->conditionVariableWriter_;
}
template<bool bIsWriteRecursionAllowed>
AuUInt32 *RWLockImpl<bIsWriteRecursionAllowed>::GetReadSleepCounter()
{
return (AuUInt32 *)this->conditionVariable_;
}
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::LockReadNSAbs(AuUInt64 uTimeout)
{
AuInt32 iCurState {};
bool bRet {};
if (this->TryLockRead())
{
return true;
}
auto pCounter = this->GetReadSleepCounter();
do
{
2023-09-19 16:08:06 +00:00
iCurState = this->iState_;
if (iCurState < 0)
{
if (gUseFutexRWLock)
{
AuAtomicAdd(pCounter, 1u);
2023-09-19 16:08:06 +00:00
bRet = InternalLTSWaitOnAddressHighRes((const void *)&this->iState_, &iCurState, sizeof(iCurState), uTimeout);
AuAtomicSub(pCounter, 1u);
if (!bRet)
{
return false;
}
}
else
{
2023-09-19 16:08:06 +00:00
RWLockAcquire;
2023-09-19 16:08:06 +00:00
iCurState = this->iState_;
if (iCurState < 0)
{
AuInt64 iSecondTimeout {};
if (uTimeout)
{
iSecondTimeout = AuInt64(uTimeout) - AuTime::SteadyClockNS();
if (iSecondTimeout <= 0)
{
return false;
}
}
#if defined(AURWLOCK_NO_SIZE_OPTIMIZED_CONDVAR)
if (!this->GetCondition().WaitForSignalNS(iSecondTimeout))
#else
if (!this->GetCondition().WaitForSignalNsEx(&this->mutex_, iSecondTimeout))
#endif
{
return false;
}
}
}
}
}
while (iCurState < 0 ||
2023-09-19 16:08:06 +00:00
AuAtomicCompareExchange(&this->iState_, iCurState + 1, iCurState) != iCurState);
return true;
}
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::LockReadNS(AuUInt64 uTimeout)
2021-06-27 21:25:29 +00:00
{
AuInt32 iCurState {};
bool bRet {};
if (this->TryLockReadNoSpin<true>())
{
return true;
}
AuInt64 uEndTime = uTimeout ? AuTime::SteadyClockNS() + uTimeout : 0;
if (this->TryLockRead())
{
return true;
}
auto pCounter = this->GetReadSleepCounter();
do
{
2023-09-19 16:08:06 +00:00
iCurState = this->iState_;
if (iCurState < 0)
{
if (gUseFutexRWLock)
{
AuAtomicAdd(pCounter, 1u);
2023-09-19 16:08:06 +00:00
bRet = InternalLTSWaitOnAddressHighRes((const void *)&this->iState_, &iCurState, sizeof(iCurState), uEndTime);
AuAtomicSub(pCounter, 1u);
if (!bRet)
{
return false;
}
}
else
{
2023-09-19 16:08:06 +00:00
RWLockAcquire;
2023-09-19 16:08:06 +00:00
iCurState = this->iState_;
if (iCurState < 0)
{
AuInt64 iSecondTimeout {};
if (uTimeout)
{
iSecondTimeout = uEndTime - AuTime::SteadyClockNS();
if (iSecondTimeout <= 0)
{
return false;
}
}
#if defined(AURWLOCK_NO_SIZE_OPTIMIZED_CONDVAR)
if (!this->GetCondition().WaitForSignalNS(iSecondTimeout))
#else
if (!this->GetCondition().WaitForSignalNsEx(&this->mutex_, iSecondTimeout))
#endif
{
return false;
}
}
}
}
}
while (iCurState < 0 ||
2023-09-19 16:08:06 +00:00
AuAtomicCompareExchange(&this->iState_, iCurState + 1, iCurState) != iCurState);
2021-06-27 21:25:29 +00:00
return true;
}
2023-09-19 16:08:06 +00:00
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::TryLockWriteMaybeSpin()
{
if (this->TryLockWriteNoSpin())
{
return true;
}
2023-09-19 16:08:06 +00:00
if (gUseFutexRWLock)
{
if (DoTryIf([=]()
{
return this->TryLockWriteNoSpin();
}))
{
return true;
}
}
return false;
}
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::LockWriteNSAbs(AuUInt64 uTimeout)
{
bool bRet {};
if (this->TryLockWriteMaybeSpin())
{
return true;
}
2023-09-19 16:08:06 +00:00
AuAtomicAdd(&this->dwWritersPending_, 1);
if (gUseFutexRWLock)
{
bRet = this->LockWriteNSAbsUnlocked(uTimeout);
}
else
{
2023-09-19 16:08:06 +00:00
RWLockAcquire;
bRet = this->LockWriteNSAbsUnlocked(uTimeout);
}
2023-09-19 16:08:06 +00:00
AuAtomicSub(&this->dwWritersPending_, 1);
return bRet;
}
template<bool bIsWriteRecursionAllowed>
2023-09-19 16:08:06 +00:00
bool RWLockImpl<bIsWriteRecursionAllowed>::TryLockWriteNoSpin()
{
2023-09-19 16:08:06 +00:00
auto uOld = this->iState_;
if constexpr (bIsWriteRecursionAllowed)
{
if (uOld < 0)
{
if (this->reentrantWriteLockHandle_ == GetThreadCookie())
{
2023-09-19 16:08:06 +00:00
AuAtomicSub(&this->iState_, 1);
return true;
}
}
}
if (uOld == 0)
{
2023-09-19 16:08:06 +00:00
if (AuAtomicCompareExchange(&this->iState_, -1, uOld) == uOld)
{
this->reentrantWriteLockHandle_ = GetThreadCookie();
return true;
}
}
return false;
}
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::LockWriteNS(AuUInt64 uTimeout)
2021-06-27 21:25:29 +00:00
{
bool bRet {};
AuInt64 uEndTime {};
if (this->TryLockWriteMaybeSpin())
{
return true;
}
2023-09-19 16:08:06 +00:00
AuAtomicAdd(&this->dwWritersPending_, 1);
if (gUseFutexRWLock)
{
uEndTime = uTimeout ? AuTime::SteadyClockNS() + uTimeout : 0;
[*/+/-] MEGA COMMIT. ~2 weeks compressed. The intention is to quickly improve and add util apis, enhance functionality given current demands, go back to the build pipeline, finish that, publish runtime tests, and then use what we have to go back to to linux support with a more stable api. [+] AuMakeSharedArray [+] Technet ArgvQuote [+] Grug subsystem (UNIX signal thread async safe ipc + telemetry flusher + log flusher.) [+] auEndianness -> Endian swap utils [+] AuGet<N>(...) [*] AUE_DEFINE conversion for ECompresionType, EAnsiColor, EHashType, EStreamError, EHexDump [+] ConsoleMessage ByteBuffer serialization [+] CmdLine subsystem for parsing command line arguments and simple switch/flag checks [*] Split logger from console subsystem [+] StartupParameters -> A part of a clean up effort under Process [*] Refactor SysErrors header + get caller hack [+] Atomic APIs [+] popcnt [+] Ring Buffer sink [+] Added more standard errors Catch, Submission, LockError, NoAccess, ResourceMissing, ResourceLocked, MalformedData, InSandboxContext, ParseError [+] Added ErrorCategorySet, ErrorCategoryClear, GetStackTrace [+] IExitSubscriber, ETriggerLevel [*] Write bias the high performance RWLockImpl read-lock operation operation [+] ExitHandlerAdd/ExitHandlerRemove (exit subsystem) [*] Updated API style Digests [+] CpuId::CpuBitCount [+] GetUserProgramsFolder [+] GetPackagePath [*] Split IStreamReader with an inl file [*] BlobWriter/BlobReader/BlobArbitraryReader can now take shared pointers to bytebuffers. default constructor allocates a new scalable bytebuffer [+] ICharacterProvider [+] ICharacterProviderEx [+] IBufferedCharacterConsumer [+] ProviderFromSharedString [+] ProviderFromString [+] BufferConsumerFromProvider [*] Parse Subsystem uses character io bufferer [*] Rewritten NT's high perf semaphore to use userland SRW/ConVars [like mutex, based on generic semaphore] [+] ByteBuffer::ResetReadPointer [*] Bug fix bytebuffer base not reset on free and some scaling issues [+] ProcessMap -> Added kSectionNameStack, kSectionNameFile, kSectionNameHeap for Section [*] ProcessMap -> Refactor Segment to Section. I was stupid for keeping a type conflict hack API facing [+] Added 64 *byte* fast RNG seeds [+] File Advisorys/File Lock Awareness [+] Added extended IAuroraThread from OS identifier caches for debug purposes [*] Tweaked how memory is reported on Windows. Better consistency of what values mean across functions. [*] Broke AuroraUtils/Typedefs out into a separate library [*] Update build script [+] Put some more effort into adding detail to the readme before rewriting it, plus, added some media [*] Improved public API documentation [*] Bug fix `SetConsoleCtrlHandler` [+] Locale TimeDateToFileNameISO8601 [+] Console config stdOutShortTime [*] Begin using internal UTF8/16 decoders when platform support isnt available (instead of stl) [*] Bug fixes in decoders [*] Major bug fix, AuMax [+] RateLimiter [+] Binary file sink [+] Log directory sink [*] Data header usability (more operators) [+] AuRemoveRange [+] AuRemove [+] AuTryRemove [+] AuTryRemoveRange [+] auCastUtils [+] Finish NewLSWin32Source [+] AuTryFindByTupleN, AuTryRemoveByTupleN [+] Separated AuRead/Write types, now in auTypeUtils [+] Added GetPosition/SetPosition to FileWriter [*] Fix stupid AuMin in place of AuMax in SpawnThread.Unix.Cpp [*] Refactored Arbitrary readers to SeekingReaders (as in, they could be atomic and/or parallelized, and accept an arbitrary position as a work parameter -> not Seekable, as in, you can simply set the position) [*] Hack back in the sched deinit [+] File AIO loop source interop [+] Begin to prototype a LoopQueue object I had in mind for NT, untested btw [+] Stub code for networking [+] Compression BaseStream/IngestableStreamBase [*] Major: read/write locks now support write-entrant read routines. [*] Compression subsystem now uses the MemoryView concept [*] Rewrite the base stream compressions, made them less broken [*] Update hashing api [*] WriterTryGoForward and ReaderTryGoForward now revert to the previous relative index instead of panicing [+] Added new AuByteBuffer apis Trim, Pad, WriteFrom, WriteString, [TODO: ReadString] [+] Added ByteBufferPushReadState [+] Added ByteBufferPushWriteState [*] Move from USC-16 to full UTF-16. Win32 can handle full UTF-16. [*] ELogLevel is now an Aurora enum [+] Raised arbitrary limit in header to 255, the max filter buffer [+] Explicit GZip support [+] Explicit Zip support [+] Added [some] compressors et al
2022-02-17 00:11:40 +00:00
bRet = this->LockWriteNSAbsUnlocked(uEndTime);
}
else
{
uEndTime = uTimeout ? AuTime::SteadyClockNS() + uTimeout : 0;
2023-09-19 16:08:06 +00:00
RWLockAcquire;
bRet = this->LockWriteNSAbsUnlocked(uEndTime);
}
2023-09-19 16:08:06 +00:00
AuAtomicSub(&this->dwWritersPending_, 1);
return bRet;
}
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::LockWriteNSAbsUnlocked(AuUInt64 qwTimeoutNS)
{
while (true)
2021-06-27 21:25:29 +00:00
{
2023-09-19 16:08:06 +00:00
if (this->WriterSleep(qwTimeoutNS))
{
2023-09-19 16:08:06 +00:00
if (this->WriterTryLock())
{
2023-09-19 16:08:06 +00:00
return true;
}
}
else
{
return this->WriterTryLock();
}
}
}
template<bool bIsWriteRecursionAllowed>
void RWLockImpl<bIsWriteRecursionAllowed>::FutexWriterWake()
{
auto pSemaphore = this->GetFutexConditionWriter();
while (true)
{
auto uState = *pSemaphore;
2023-09-19 16:08:06 +00:00
if (uState == 0)
{
break;
}
2023-09-19 16:08:06 +00:00
if (AuAtomicCompareExchange(pSemaphore, uState - 1, uState) == uState)
{
break;
}
}
}
2023-09-19 16:08:06 +00:00
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::WriterTryLock()
{
if (AuAtomicCompareExchange(&this->iState_, -1, 0) == 0)
{
this->reentrantWriteLockHandle_ = GetThreadCookie();
return true;
}
else
{
return false;
}
}
2023-09-19 16:08:06 +00:00
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::WriterSleep(AuUInt64 qwTimeoutNS)
{
bool bStatus { true };
AuInt32 iCurState;
2023-09-19 16:08:06 +00:00
auto pSemaphore = this->GetFutexConditionWriter();
2023-09-19 16:08:06 +00:00
while ((iCurState = AuAtomicLoad(&this->iState_)) != 0)
{
AuInt64 uSecondTimeout = 0;
2023-09-19 16:08:06 +00:00
if (gUseFutexRWLock)
{
static const AuUInt32 kExpect { 0 };
bStatus = InternalLTSWaitOnAddressHighRes(pSemaphore, &kExpect, sizeof(kExpect), qwTimeoutNS);
this->WriterWake();
if (!bStatus)
{
return false;
}
2023-09-19 16:08:06 +00:00
this->FutexWriterWake();
}
else
{
if (qwTimeoutNS)
{
2023-09-19 16:08:06 +00:00
uSecondTimeout = qwTimeoutNS - AuTime::SteadyClockNS();
if (uSecondTimeout <= 0)
{
2023-09-19 16:08:06 +00:00
return false;
}
}
2023-09-19 16:08:06 +00:00
#if defined(AURWLOCK_NO_SIZE_OPTIMIZED_CONDVAR)
bStatus = this->GetConditionWriter().WaitForSignalNS(uSecondTimeout);
#else
bStatus = this->GetConditionWriter().WaitForSignalNsEx(&this->mutex_, uSecondTimeout);
#endif
this->WriterWake();
if (!bStatus)
{
2023-09-19 16:08:06 +00:00
continue;
}
}
}
2021-06-27 21:25:29 +00:00
return true;
}
2023-09-19 16:08:06 +00:00
template<bool bIsWriteRecursionAllowed>
void RWLockImpl<bIsWriteRecursionAllowed>::WriterWake()
{
if (AuAtomicLoad(&this->iState_) == 1 &&
AuAtomicLoad(&this->dwWritersPending_) > 1)
{
this->SignalManyWriter(-1);
}
}
template<bool bIsWriteRecursionAllowed>
void RWLockImpl<bIsWriteRecursionAllowed>::SignalOneReader()
2023-09-19 16:08:06 +00:00
{
// Unused method!
if (gUseFutexRWLock)
{
2023-09-19 16:08:06 +00:00
InternalLTSWakeOne((const void *)&this->iState_);
}
else
{
2023-09-23 01:40:23 +00:00
RWLockBarrierSelf();
this->GetCondition().Signal();
}
}
template<bool bIsWriteRecursionAllowed>
void RWLockImpl<bIsWriteRecursionAllowed>::SignalOneWriter()
{
if (gUseFutexRWLock)
{
auto pThat = this->GetFutexConditionWriter();
AuAtomicAdd(pThat, 1u);
2023-09-19 16:08:06 +00:00
InternalLTSWakeOne(pThat); // Note: all paths check for a waiter ahead of time!
}
else
{
2023-09-23 01:40:23 +00:00
RWLockBarrierSelf();
this->GetConditionWriter().Signal();
}
}
template<bool bIsWriteRecursionAllowed>
void RWLockImpl<bIsWriteRecursionAllowed>::SignalManyReader()
{
if (gUseFutexRWLock)
{
if (AuAtomicLoad(this->GetReadSleepCounter()))
{
2023-09-19 16:08:06 +00:00
InternalLTSWakeAll((const void *)&this->iState_);
}
}
else
{
2023-09-23 01:40:23 +00:00
RWLockBarrierSelf();
this->GetCondition().Broadcast();
}
}
template<bool bIsWriteRecursionAllowed>
void RWLockImpl<bIsWriteRecursionAllowed>::SignalManyWriter(int iBias)
{
if (gUseFutexRWLock)
{
auto pThat = this->GetFutexConditionWriter();
2023-09-19 16:08:06 +00:00
if (auto uCount = AuUInt32(AuAtomicLoad(&this->dwWritersPending_) + iBias))
{
AuAtomicAdd(pThat, uCount);
InternalLTSWakeCount(pThat, uCount);
}
}
else
{
2023-09-23 01:40:23 +00:00
RWLockBarrierSelf();
this->GetConditionWriter().Broadcast();
}
}
2021-06-27 21:25:29 +00:00
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::TryLockRead()
2021-06-27 21:25:29 +00:00
{
if (this->TryLockReadNoSpin<true>())
{
return true;
}
if (ThrdCfg::gPreferRWLockReadLockSpin &&
2023-09-19 16:08:06 +00:00
AuAtomicLoad(&this->dwWritersPending_) == 0)
{
return DoTryIf([=]()
{
2023-09-09 18:46:08 +00:00
return this->TryLockReadNoSpin<true>();
});
}
return false;
}
template<bool bIsWriteRecursionAllowed>
2023-09-19 16:08:06 +00:00
template<bool bCheckWrite>
bool RWLockImpl<bIsWriteRecursionAllowed>::TryLockReadNoSpin()
{
2023-09-19 16:08:06 +00:00
auto iCurState = this->iState_;
2021-06-27 21:25:29 +00:00
if (iCurState < 0)
{
return this->reentrantWriteLockHandle_ == GetThreadCookie();
}
2023-09-19 16:08:06 +00:00
if constexpr (bCheckWrite)
{
2023-09-19 16:08:06 +00:00
if ((AuAtomicLoad(&this->dwWritersPending_)) &&
(iCurState > 0 || ThrdCfg::gAlwaysRWLockWriteBiasOnReadLock) &&
(ThrdCfg::gEnableRWLockWriteBiasOnReadLock))
{
return false;
}
}
2023-09-19 16:08:06 +00:00
return AuAtomicCompareExchange(&this->iState_, iCurState + 1, iCurState) == iCurState;
2021-06-27 21:25:29 +00:00
}
template<bool bIsWriteRecursionAllowed>
void RWLockImpl<bIsWriteRecursionAllowed>::UnlockRead()
2021-06-27 21:25:29 +00:00
{
2023-07-30 10:10:08 +00:00
AuInt32 uVal {};
2023-09-19 16:08:06 +00:00
if (this->iState_ < 0)
[*/+/-] MEGA COMMIT. ~2 weeks compressed. The intention is to quickly improve and add util apis, enhance functionality given current demands, go back to the build pipeline, finish that, publish runtime tests, and then use what we have to go back to to linux support with a more stable api. [+] AuMakeSharedArray [+] Technet ArgvQuote [+] Grug subsystem (UNIX signal thread async safe ipc + telemetry flusher + log flusher.) [+] auEndianness -> Endian swap utils [+] AuGet<N>(...) [*] AUE_DEFINE conversion for ECompresionType, EAnsiColor, EHashType, EStreamError, EHexDump [+] ConsoleMessage ByteBuffer serialization [+] CmdLine subsystem for parsing command line arguments and simple switch/flag checks [*] Split logger from console subsystem [+] StartupParameters -> A part of a clean up effort under Process [*] Refactor SysErrors header + get caller hack [+] Atomic APIs [+] popcnt [+] Ring Buffer sink [+] Added more standard errors Catch, Submission, LockError, NoAccess, ResourceMissing, ResourceLocked, MalformedData, InSandboxContext, ParseError [+] Added ErrorCategorySet, ErrorCategoryClear, GetStackTrace [+] IExitSubscriber, ETriggerLevel [*] Write bias the high performance RWLockImpl read-lock operation operation [+] ExitHandlerAdd/ExitHandlerRemove (exit subsystem) [*] Updated API style Digests [+] CpuId::CpuBitCount [+] GetUserProgramsFolder [+] GetPackagePath [*] Split IStreamReader with an inl file [*] BlobWriter/BlobReader/BlobArbitraryReader can now take shared pointers to bytebuffers. default constructor allocates a new scalable bytebuffer [+] ICharacterProvider [+] ICharacterProviderEx [+] IBufferedCharacterConsumer [+] ProviderFromSharedString [+] ProviderFromString [+] BufferConsumerFromProvider [*] Parse Subsystem uses character io bufferer [*] Rewritten NT's high perf semaphore to use userland SRW/ConVars [like mutex, based on generic semaphore] [+] ByteBuffer::ResetReadPointer [*] Bug fix bytebuffer base not reset on free and some scaling issues [+] ProcessMap -> Added kSectionNameStack, kSectionNameFile, kSectionNameHeap for Section [*] ProcessMap -> Refactor Segment to Section. I was stupid for keeping a type conflict hack API facing [+] Added 64 *byte* fast RNG seeds [+] File Advisorys/File Lock Awareness [+] Added extended IAuroraThread from OS identifier caches for debug purposes [*] Tweaked how memory is reported on Windows. Better consistency of what values mean across functions. [*] Broke AuroraUtils/Typedefs out into a separate library [*] Update build script [+] Put some more effort into adding detail to the readme before rewriting it, plus, added some media [*] Improved public API documentation [*] Bug fix `SetConsoleCtrlHandler` [+] Locale TimeDateToFileNameISO8601 [+] Console config stdOutShortTime [*] Begin using internal UTF8/16 decoders when platform support isnt available (instead of stl) [*] Bug fixes in decoders [*] Major bug fix, AuMax [+] RateLimiter [+] Binary file sink [+] Log directory sink [*] Data header usability (more operators) [+] AuRemoveRange [+] AuRemove [+] AuTryRemove [+] AuTryRemoveRange [+] auCastUtils [+] Finish NewLSWin32Source [+] AuTryFindByTupleN, AuTryRemoveByTupleN [+] Separated AuRead/Write types, now in auTypeUtils [+] Added GetPosition/SetPosition to FileWriter [*] Fix stupid AuMin in place of AuMax in SpawnThread.Unix.Cpp [*] Refactored Arbitrary readers to SeekingReaders (as in, they could be atomic and/or parallelized, and accept an arbitrary position as a work parameter -> not Seekable, as in, you can simply set the position) [*] Hack back in the sched deinit [+] File AIO loop source interop [+] Begin to prototype a LoopQueue object I had in mind for NT, untested btw [+] Stub code for networking [+] Compression BaseStream/IngestableStreamBase [*] Major: read/write locks now support write-entrant read routines. [*] Compression subsystem now uses the MemoryView concept [*] Rewrite the base stream compressions, made them less broken [*] Update hashing api [*] WriterTryGoForward and ReaderTryGoForward now revert to the previous relative index instead of panicing [+] Added new AuByteBuffer apis Trim, Pad, WriteFrom, WriteString, [TODO: ReadString] [+] Added ByteBufferPushReadState [+] Added ByteBufferPushWriteState [*] Move from USC-16 to full UTF-16. Win32 can handle full UTF-16. [*] ELogLevel is now an Aurora enum [+] Raised arbitrary limit in header to 255, the max filter buffer [+] Explicit GZip support [+] Explicit Zip support [+] Added [some] compressors et al
2022-02-17 00:11:40 +00:00
{
SysAssertDbg(this->reentrantWriteLockHandle_ == GetThreadCookie());
[*/+/-] MEGA COMMIT. ~2 weeks compressed. The intention is to quickly improve and add util apis, enhance functionality given current demands, go back to the build pipeline, finish that, publish runtime tests, and then use what we have to go back to to linux support with a more stable api. [+] AuMakeSharedArray [+] Technet ArgvQuote [+] Grug subsystem (UNIX signal thread async safe ipc + telemetry flusher + log flusher.) [+] auEndianness -> Endian swap utils [+] AuGet<N>(...) [*] AUE_DEFINE conversion for ECompresionType, EAnsiColor, EHashType, EStreamError, EHexDump [+] ConsoleMessage ByteBuffer serialization [+] CmdLine subsystem for parsing command line arguments and simple switch/flag checks [*] Split logger from console subsystem [+] StartupParameters -> A part of a clean up effort under Process [*] Refactor SysErrors header + get caller hack [+] Atomic APIs [+] popcnt [+] Ring Buffer sink [+] Added more standard errors Catch, Submission, LockError, NoAccess, ResourceMissing, ResourceLocked, MalformedData, InSandboxContext, ParseError [+] Added ErrorCategorySet, ErrorCategoryClear, GetStackTrace [+] IExitSubscriber, ETriggerLevel [*] Write bias the high performance RWLockImpl read-lock operation operation [+] ExitHandlerAdd/ExitHandlerRemove (exit subsystem) [*] Updated API style Digests [+] CpuId::CpuBitCount [+] GetUserProgramsFolder [+] GetPackagePath [*] Split IStreamReader with an inl file [*] BlobWriter/BlobReader/BlobArbitraryReader can now take shared pointers to bytebuffers. default constructor allocates a new scalable bytebuffer [+] ICharacterProvider [+] ICharacterProviderEx [+] IBufferedCharacterConsumer [+] ProviderFromSharedString [+] ProviderFromString [+] BufferConsumerFromProvider [*] Parse Subsystem uses character io bufferer [*] Rewritten NT's high perf semaphore to use userland SRW/ConVars [like mutex, based on generic semaphore] [+] ByteBuffer::ResetReadPointer [*] Bug fix bytebuffer base not reset on free and some scaling issues [+] ProcessMap -> Added kSectionNameStack, kSectionNameFile, kSectionNameHeap for Section [*] ProcessMap -> Refactor Segment to Section. I was stupid for keeping a type conflict hack API facing [+] Added 64 *byte* fast RNG seeds [+] File Advisorys/File Lock Awareness [+] Added extended IAuroraThread from OS identifier caches for debug purposes [*] Tweaked how memory is reported on Windows. Better consistency of what values mean across functions. [*] Broke AuroraUtils/Typedefs out into a separate library [*] Update build script [+] Put some more effort into adding detail to the readme before rewriting it, plus, added some media [*] Improved public API documentation [*] Bug fix `SetConsoleCtrlHandler` [+] Locale TimeDateToFileNameISO8601 [+] Console config stdOutShortTime [*] Begin using internal UTF8/16 decoders when platform support isnt available (instead of stl) [*] Bug fixes in decoders [*] Major bug fix, AuMax [+] RateLimiter [+] Binary file sink [+] Log directory sink [*] Data header usability (more operators) [+] AuRemoveRange [+] AuRemove [+] AuTryRemove [+] AuTryRemoveRange [+] auCastUtils [+] Finish NewLSWin32Source [+] AuTryFindByTupleN, AuTryRemoveByTupleN [+] Separated AuRead/Write types, now in auTypeUtils [+] Added GetPosition/SetPosition to FileWriter [*] Fix stupid AuMin in place of AuMax in SpawnThread.Unix.Cpp [*] Refactored Arbitrary readers to SeekingReaders (as in, they could be atomic and/or parallelized, and accept an arbitrary position as a work parameter -> not Seekable, as in, you can simply set the position) [*] Hack back in the sched deinit [+] File AIO loop source interop [+] Begin to prototype a LoopQueue object I had in mind for NT, untested btw [+] Stub code for networking [+] Compression BaseStream/IngestableStreamBase [*] Major: read/write locks now support write-entrant read routines. [*] Compression subsystem now uses the MemoryView concept [*] Rewrite the base stream compressions, made them less broken [*] Update hashing api [*] WriterTryGoForward and ReaderTryGoForward now revert to the previous relative index instead of panicing [+] Added new AuByteBuffer apis Trim, Pad, WriteFrom, WriteString, [TODO: ReadString] [+] Added ByteBufferPushReadState [+] Added ByteBufferPushWriteState [*] Move from USC-16 to full UTF-16. Win32 can handle full UTF-16. [*] ELogLevel is now an Aurora enum [+] Raised arbitrary limit in header to 255, the max filter buffer [+] Explicit GZip support [+] Explicit Zip support [+] Added [some] compressors et al
2022-02-17 00:11:40 +00:00
return;
}
2021-06-27 21:25:29 +00:00
2023-09-19 16:08:06 +00:00
uVal = AuAtomicSub(&this->iState_, 1);
bool bAlt {};
if constexpr (bIsWriteRecursionAllowed)
{
bAlt = uVal == 1;
}
if (uVal == 0 || bAlt)
{
2023-09-23 01:40:23 +00:00
if (AuAtomicLoad(&this->dwWritersPending_) > 0)
2023-07-30 10:10:08 +00:00
{
this->SignalOneWriter();
2023-07-30 10:10:08 +00:00
}
}
2021-06-27 21:25:29 +00:00
}
template<bool bIsWriteRecursionAllowed>
void RWLockImpl<bIsWriteRecursionAllowed>::UnlockWrite()
2021-06-27 21:25:29 +00:00
{
if constexpr (!bIsWriteRecursionAllowed)
{
2023-07-30 10:10:08 +00:00
this->reentrantWriteLockHandle_ = 0;
2023-09-23 01:40:23 +00:00
AuAtomicStore(&this->iState_, 0);
2023-09-23 01:40:23 +00:00
if (AuAtomicLoad(&this->dwWritersPending_) > 0)
2023-07-30 10:10:08 +00:00
{
this->SignalOneWriter();
2023-07-30 10:10:08 +00:00
}
else
{
this->SignalManyReader();
2023-07-30 10:10:08 +00:00
}
}
else
{
AuInt32 val {};
// love me cas
{
AuInt32 curVal {};
do
{
2023-09-19 16:08:06 +00:00
curVal = this->iState_;
if (curVal != -1)
{
continue;
}
this->reentrantWriteLockHandle_ = 0;
}
2023-09-19 16:08:06 +00:00
while (AuAtomicCompareExchange(&this->iState_, val = (curVal + 1), curVal) != curVal);
}
if (val == 0)
{
2023-09-23 01:40:23 +00:00
if (AuAtomicLoad(&this->dwWritersPending_) > 0)
2023-07-30 10:10:08 +00:00
{
this->SignalOneWriter();
2023-07-30 10:10:08 +00:00
}
else
{
this->SignalManyReader();
2023-07-30 10:10:08 +00:00
}
}
}
2021-06-27 21:25:29 +00:00
}
2021-09-06 10:58:08 +00:00
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::UpgradeReadToWrite(AuUInt64 uTimeout)
2021-09-06 10:58:08 +00:00
{
2023-09-19 16:08:06 +00:00
if (this->iState_ == 1)
{
if (this->UpgradeReadToWriteDoUpgrade())
{
return true;
}
}
auto uEndTime = uTimeout ? AuTime::SteadyClockNS() + uTimeout : 0;
if (!gUseFutexRWLock)
2021-09-06 10:58:08 +00:00
{
2023-09-19 16:08:06 +00:00
AuAtomicAdd(&this->dwWritersPending_, 1);
RWLockAcquire;
2023-09-19 16:08:06 +00:00
while (this->iState_ != 1)
{
AuInt64 iSecondTimeout {};
if (uTimeout)
{
iSecondTimeout = AuInt64(uEndTime) - AuTime::SteadyClockNS();
if (iSecondTimeout <= 0)
{
2023-09-19 16:08:06 +00:00
AuAtomicSub(&this->dwWritersPending_, 1);
return false;
}
}
#if defined(AURWLOCK_NO_SIZE_OPTIMIZED_CONDVAR)
if (!this->GetConditionWriter().WaitForSignalNS(iSecondTimeout))
#else
if (!this->GetConditionWriter().WaitForSignalNsEx(&this->mutex_, iSecondTimeout))
#endif
{
2023-09-19 16:08:06 +00:00
AuAtomicSub(&this->dwWritersPending_, 1);
return false;
}
}
2023-09-19 16:08:06 +00:00
AuAtomicSub(&this->dwWritersPending_, 1);
return this->UpgradeReadToWriteDoUpgrade();
}
else
{
while (true)
2021-09-06 10:58:08 +00:00
{
auto pSemaphore = this->GetFutexConditionWriter();
AuInt32 iCurState;
2023-09-19 16:08:06 +00:00
while ((iCurState = AuAtomicLoad(&this->iState_)) != 1)
{
bool bStatusTwo {};
bool bStatus {};
2023-09-19 16:08:06 +00:00
AuAtomicAdd(&this->dwWritersPending_, 1);
static const AuUInt32 kExpect { 0 };
2023-09-19 16:08:06 +00:00
if ((iCurState = AuAtomicLoad(&this->iState_)) == 1)
{
bStatus = true;
bStatusTwo = true;
}
else
{
bStatus = InternalLTSWaitOnAddressHighRes(pSemaphore, &kExpect, sizeof(kExpect), uEndTime);
}
2023-09-19 16:08:06 +00:00
AuAtomicSub(&this->dwWritersPending_, 1);
if (!bStatus)
{
return false;
}
if (!bStatusTwo)
{
while (true)
{
auto uState = *pSemaphore;
if (uState == 0)
{
break;
}
if (AuAtomicCompareExchange(pSemaphore, uState - 1, uState) == uState)
{
break;
}
}
}
}
if (this->UpgradeReadToWriteDoUpgrade())
{
return true;
}
2021-09-06 10:58:08 +00:00
}
}
/* unreachable */
return false;
}
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::UpgradeReadToWriteDoUpgrade()
{
2023-09-19 16:08:06 +00:00
if (AuAtomicCompareExchange(&this->iState_, -1, 1) == 1)
{
this->reentrantWriteLockHandle_ = GetThreadCookie();
return true;
}
else
{
return false;
}
2021-09-06 10:58:08 +00:00
}
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::DowngradeWriteToRead()
2022-03-30 11:32:03 +00:00
{
2023-09-19 16:08:06 +00:00
if (AuAtomicCompareExchange(&this->iState_, 1, -1) == -1)
{
2023-09-19 16:08:06 +00:00
this->SignalManyReader();
return true;
}
else
2022-03-30 11:32:03 +00:00
{
2023-09-19 16:08:06 +00:00
return false;
2022-03-30 11:32:03 +00:00
}
}
template<bool bIsWriteRecursionAllowed>
IWaitable *RWLockImpl<bIsWriteRecursionAllowed>::AsReadable()
2021-06-27 21:25:29 +00:00
{
[*/+/-] MEGA COMMIT. ~2 weeks compressed. The intention is to quickly improve and add util apis, enhance functionality given current demands, go back to the build pipeline, finish that, publish runtime tests, and then use what we have to go back to to linux support with a more stable api. [+] AuMakeSharedArray [+] Technet ArgvQuote [+] Grug subsystem (UNIX signal thread async safe ipc + telemetry flusher + log flusher.) [+] auEndianness -> Endian swap utils [+] AuGet<N>(...) [*] AUE_DEFINE conversion for ECompresionType, EAnsiColor, EHashType, EStreamError, EHexDump [+] ConsoleMessage ByteBuffer serialization [+] CmdLine subsystem for parsing command line arguments and simple switch/flag checks [*] Split logger from console subsystem [+] StartupParameters -> A part of a clean up effort under Process [*] Refactor SysErrors header + get caller hack [+] Atomic APIs [+] popcnt [+] Ring Buffer sink [+] Added more standard errors Catch, Submission, LockError, NoAccess, ResourceMissing, ResourceLocked, MalformedData, InSandboxContext, ParseError [+] Added ErrorCategorySet, ErrorCategoryClear, GetStackTrace [+] IExitSubscriber, ETriggerLevel [*] Write bias the high performance RWLockImpl read-lock operation operation [+] ExitHandlerAdd/ExitHandlerRemove (exit subsystem) [*] Updated API style Digests [+] CpuId::CpuBitCount [+] GetUserProgramsFolder [+] GetPackagePath [*] Split IStreamReader with an inl file [*] BlobWriter/BlobReader/BlobArbitraryReader can now take shared pointers to bytebuffers. default constructor allocates a new scalable bytebuffer [+] ICharacterProvider [+] ICharacterProviderEx [+] IBufferedCharacterConsumer [+] ProviderFromSharedString [+] ProviderFromString [+] BufferConsumerFromProvider [*] Parse Subsystem uses character io bufferer [*] Rewritten NT's high perf semaphore to use userland SRW/ConVars [like mutex, based on generic semaphore] [+] ByteBuffer::ResetReadPointer [*] Bug fix bytebuffer base not reset on free and some scaling issues [+] ProcessMap -> Added kSectionNameStack, kSectionNameFile, kSectionNameHeap for Section [*] ProcessMap -> Refactor Segment to Section. I was stupid for keeping a type conflict hack API facing [+] Added 64 *byte* fast RNG seeds [+] File Advisorys/File Lock Awareness [+] Added extended IAuroraThread from OS identifier caches for debug purposes [*] Tweaked how memory is reported on Windows. Better consistency of what values mean across functions. [*] Broke AuroraUtils/Typedefs out into a separate library [*] Update build script [+] Put some more effort into adding detail to the readme before rewriting it, plus, added some media [*] Improved public API documentation [*] Bug fix `SetConsoleCtrlHandler` [+] Locale TimeDateToFileNameISO8601 [+] Console config stdOutShortTime [*] Begin using internal UTF8/16 decoders when platform support isnt available (instead of stl) [*] Bug fixes in decoders [*] Major bug fix, AuMax [+] RateLimiter [+] Binary file sink [+] Log directory sink [*] Data header usability (more operators) [+] AuRemoveRange [+] AuRemove [+] AuTryRemove [+] AuTryRemoveRange [+] auCastUtils [+] Finish NewLSWin32Source [+] AuTryFindByTupleN, AuTryRemoveByTupleN [+] Separated AuRead/Write types, now in auTypeUtils [+] Added GetPosition/SetPosition to FileWriter [*] Fix stupid AuMin in place of AuMax in SpawnThread.Unix.Cpp [*] Refactored Arbitrary readers to SeekingReaders (as in, they could be atomic and/or parallelized, and accept an arbitrary position as a work parameter -> not Seekable, as in, you can simply set the position) [*] Hack back in the sched deinit [+] File AIO loop source interop [+] Begin to prototype a LoopQueue object I had in mind for NT, untested btw [+] Stub code for networking [+] Compression BaseStream/IngestableStreamBase [*] Major: read/write locks now support write-entrant read routines. [*] Compression subsystem now uses the MemoryView concept [*] Rewrite the base stream compressions, made them less broken [*] Update hashing api [*] WriterTryGoForward and ReaderTryGoForward now revert to the previous relative index instead of panicing [+] Added new AuByteBuffer apis Trim, Pad, WriteFrom, WriteString, [TODO: ReadString] [+] Added ByteBufferPushReadState [+] Added ByteBufferPushWriteState [*] Move from USC-16 to full UTF-16. Win32 can handle full UTF-16. [*] ELogLevel is now an Aurora enum [+] Raised arbitrary limit in header to 255, the max filter buffer [+] Explicit GZip support [+] Explicit Zip support [+] Added [some] compressors et al
2022-02-17 00:11:40 +00:00
return &this->read_;
2021-06-27 21:25:29 +00:00
}
template<bool bIsWriteRecursionAllowed>
IWaitable *RWLockImpl<bIsWriteRecursionAllowed>::AsWritable()
2021-06-27 21:25:29 +00:00
{
[*/+/-] MEGA COMMIT. ~2 weeks compressed. The intention is to quickly improve and add util apis, enhance functionality given current demands, go back to the build pipeline, finish that, publish runtime tests, and then use what we have to go back to to linux support with a more stable api. [+] AuMakeSharedArray [+] Technet ArgvQuote [+] Grug subsystem (UNIX signal thread async safe ipc + telemetry flusher + log flusher.) [+] auEndianness -> Endian swap utils [+] AuGet<N>(...) [*] AUE_DEFINE conversion for ECompresionType, EAnsiColor, EHashType, EStreamError, EHexDump [+] ConsoleMessage ByteBuffer serialization [+] CmdLine subsystem for parsing command line arguments and simple switch/flag checks [*] Split logger from console subsystem [+] StartupParameters -> A part of a clean up effort under Process [*] Refactor SysErrors header + get caller hack [+] Atomic APIs [+] popcnt [+] Ring Buffer sink [+] Added more standard errors Catch, Submission, LockError, NoAccess, ResourceMissing, ResourceLocked, MalformedData, InSandboxContext, ParseError [+] Added ErrorCategorySet, ErrorCategoryClear, GetStackTrace [+] IExitSubscriber, ETriggerLevel [*] Write bias the high performance RWLockImpl read-lock operation operation [+] ExitHandlerAdd/ExitHandlerRemove (exit subsystem) [*] Updated API style Digests [+] CpuId::CpuBitCount [+] GetUserProgramsFolder [+] GetPackagePath [*] Split IStreamReader with an inl file [*] BlobWriter/BlobReader/BlobArbitraryReader can now take shared pointers to bytebuffers. default constructor allocates a new scalable bytebuffer [+] ICharacterProvider [+] ICharacterProviderEx [+] IBufferedCharacterConsumer [+] ProviderFromSharedString [+] ProviderFromString [+] BufferConsumerFromProvider [*] Parse Subsystem uses character io bufferer [*] Rewritten NT's high perf semaphore to use userland SRW/ConVars [like mutex, based on generic semaphore] [+] ByteBuffer::ResetReadPointer [*] Bug fix bytebuffer base not reset on free and some scaling issues [+] ProcessMap -> Added kSectionNameStack, kSectionNameFile, kSectionNameHeap for Section [*] ProcessMap -> Refactor Segment to Section. I was stupid for keeping a type conflict hack API facing [+] Added 64 *byte* fast RNG seeds [+] File Advisorys/File Lock Awareness [+] Added extended IAuroraThread from OS identifier caches for debug purposes [*] Tweaked how memory is reported on Windows. Better consistency of what values mean across functions. [*] Broke AuroraUtils/Typedefs out into a separate library [*] Update build script [+] Put some more effort into adding detail to the readme before rewriting it, plus, added some media [*] Improved public API documentation [*] Bug fix `SetConsoleCtrlHandler` [+] Locale TimeDateToFileNameISO8601 [+] Console config stdOutShortTime [*] Begin using internal UTF8/16 decoders when platform support isnt available (instead of stl) [*] Bug fixes in decoders [*] Major bug fix, AuMax [+] RateLimiter [+] Binary file sink [+] Log directory sink [*] Data header usability (more operators) [+] AuRemoveRange [+] AuRemove [+] AuTryRemove [+] AuTryRemoveRange [+] auCastUtils [+] Finish NewLSWin32Source [+] AuTryFindByTupleN, AuTryRemoveByTupleN [+] Separated AuRead/Write types, now in auTypeUtils [+] Added GetPosition/SetPosition to FileWriter [*] Fix stupid AuMin in place of AuMax in SpawnThread.Unix.Cpp [*] Refactored Arbitrary readers to SeekingReaders (as in, they could be atomic and/or parallelized, and accept an arbitrary position as a work parameter -> not Seekable, as in, you can simply set the position) [*] Hack back in the sched deinit [+] File AIO loop source interop [+] Begin to prototype a LoopQueue object I had in mind for NT, untested btw [+] Stub code for networking [+] Compression BaseStream/IngestableStreamBase [*] Major: read/write locks now support write-entrant read routines. [*] Compression subsystem now uses the MemoryView concept [*] Rewrite the base stream compressions, made them less broken [*] Update hashing api [*] WriterTryGoForward and ReaderTryGoForward now revert to the previous relative index instead of panicing [+] Added new AuByteBuffer apis Trim, Pad, WriteFrom, WriteString, [TODO: ReadString] [+] Added ByteBufferPushReadState [+] Added ByteBufferPushWriteState [*] Move from USC-16 to full UTF-16. Win32 can handle full UTF-16. [*] ELogLevel is now an Aurora enum [+] Raised arbitrary limit in header to 255, the max filter buffer [+] Explicit GZip support [+] Explicit Zip support [+] Added [some] compressors et al
2022-02-17 00:11:40 +00:00
return &this->write_;
2021-06-27 21:25:29 +00:00
}
2023-12-01 01:12:18 +00:00
template<bool bIsWriteRecursionAllowed>
bool RWLockImpl<bIsWriteRecursionAllowed>::CheckSelfThreadIsWriter()
{
return this->reentrantWriteLockHandle_ == GetThreadCookie();
}
2022-06-01 21:49:38 +00:00
AUKN_SYM IRWLock *RWLockNew()
2021-06-27 21:25:29 +00:00
{
return _new RWLockImpl<false>();
2021-06-27 21:25:29 +00:00
}
AUKN_SYM void RWLockRelease(IRWLock *pRwLock)
2021-06-27 21:25:29 +00:00
{
AuSafeDelete<RWLockImpl<false> *>(pRwLock);
}
AUKN_SYM IRWLock *RWRenterableLockNew()
{
return _new RWLockImpl<true>();
}
AUKN_SYM void RWRenterableLockRelease(IRWLock *pRwLock)
{
AuSafeDelete<RWLockImpl<true> *>(pRwLock);
2021-06-27 21:25:29 +00:00
}
AUROXTL_INTERFACE_SOO_SRC_EX(AURORA_SYMBOL_EXPORT, RWRenterableLock, RWLockImpl<true>)
AUROXTL_INTERFACE_SOO_SRC_EX(AURORA_SYMBOL_EXPORT, RWLock, RWLockImpl<false>)
2022-03-30 11:32:03 +00:00
}