[*] Refactor: FeaturefulCondition -> FlexibleConditionVariable
[+] SOO for FlexibleConditionVariable
This commit is contained in:
parent
daf6108902
commit
dab6e9caee
@ -11,10 +11,8 @@ namespace Aurora::Threading::Primitives
|
||||
{
|
||||
/**
|
||||
A comprehensive CV that does not strictly abide by typical assumptions. <br>
|
||||
This object is not optimal; however, it will work with any or no IWaitable <br>
|
||||
On systems where context switches are expensive, this object should be avoided at all costs <br>
|
||||
This object depends on the synchronization of primitives within our abstraction layer rather than the OS's implementation of condition variables. <br>
|
||||
Note: missing pWaitables cannnot serve as an `atomic wait for while is [not] value` operation as found under modern operating system schedulers.
|
||||
Note: Missing 'pWaitable's cannnot serve as an `atomic wait for while is [not] value` operation.
|
||||
There are no legal use cases for this feature. It's just there.
|
||||
*/
|
||||
struct ConditionEx
|
||||
@ -25,6 +23,6 @@ namespace Aurora::Threading::Primitives
|
||||
virtual void Broadcast() = 0;
|
||||
virtual void Signal() = 0;
|
||||
};
|
||||
|
||||
AUKN_SHARED_API(FeaturefulCondition, ConditionEx);
|
||||
|
||||
AUKN_SHARED_SOO(FlexibleConditionVariable, ConditionEx, kPrimitiveSizeSemaphoreCV);
|
||||
}
|
@ -16,6 +16,9 @@ namespace Aurora::Threading::Primitives
|
||||
{
|
||||
static const auto kDefaultPrimitiveSize64 = 128;
|
||||
|
||||
// Define all the sizes of the primitives on each platform by word-size, preprocessed to filter irrelevant/unknown architectures:
|
||||
#if defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86)
|
||||
|
||||
static const auto kPrimitiveSize64NTMutex = 16;
|
||||
static const auto kPrimitiveSize64NTSemaphore = 64;
|
||||
static const auto kPrimitiveSize64NTCS = 32;
|
||||
@ -32,6 +35,15 @@ namespace Aurora::Threading::Primitives
|
||||
static const auto kPrimitiveSize32NTCond = 20;
|
||||
static const auto kPrimitiveSize32NTCondMutex = 8;
|
||||
|
||||
// TODO: Other platforms...
|
||||
|
||||
#else
|
||||
|
||||
// TBD
|
||||
|
||||
#endif
|
||||
|
||||
// Platform selection:
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
|
||||
static const auto kPrimitiveSize64Mutex = kPrimitiveSize64NTMutex;
|
||||
@ -86,6 +98,8 @@ namespace Aurora::Threading::Primitives
|
||||
|
||||
#endif
|
||||
|
||||
static const auto kPrimitiveSizeSemaphoreCV = AuPageRoundUp<AuUInt>(8 + kPrimitiveSizeSemaphore + 4, sizeof(AuUInt));
|
||||
|
||||
struct AUKN_SYM HyperWaitable : IWaitable
|
||||
{
|
||||
auline inline void Lock() final override
|
||||
|
@ -22,8 +22,8 @@ namespace Aurora::Threading::Primitives
|
||||
void Broadcast() override;
|
||||
|
||||
private:
|
||||
AuUInt32 waiters_;
|
||||
SemaphoreImpl s_;
|
||||
AuUInt32 waiters_;
|
||||
};
|
||||
|
||||
SemaphoreConditionVariableImpl::SemaphoreConditionVariableImpl() :
|
||||
@ -106,13 +106,15 @@ namespace Aurora::Threading::Primitives
|
||||
}
|
||||
}
|
||||
|
||||
AUKN_SYM ConditionEx *FeaturefulConditionNew()
|
||||
AUKN_SYM ConditionEx *FlexibleConditionVariableNew()
|
||||
{
|
||||
return _new SemaphoreConditionVariableImpl();
|
||||
}
|
||||
|
||||
AUKN_SYM void FeaturefulConditionRelease(ConditionEx *pCVEx)
|
||||
AUKN_SYM void FlexibleConditionVariableRelease(ConditionEx *pCVEx)
|
||||
{
|
||||
AuSafeDelete<SemaphoreConditionVariableImpl *>(pCVEx);
|
||||
}
|
||||
|
||||
AUROXTL_INTERFACE_SOO_SRC_EX(AURORA_SYMBOL_EXPORT, FlexibleConditionVariable, SemaphoreConditionVariableImpl)
|
||||
}
|
Loading…
Reference in New Issue
Block a user