diff --git a/Include/Aurora/Threading/Primitives/ConditionEx.hpp b/Include/Aurora/Threading/Primitives/ConditionEx.hpp
index a71bc0aa..d6e74f96 100644
--- a/Include/Aurora/Threading/Primitives/ConditionEx.hpp
+++ b/Include/Aurora/Threading/Primitives/ConditionEx.hpp
@@ -11,10 +11,8 @@ namespace Aurora::Threading::Primitives
{
/**
A comprehensive CV that does not strictly abide by typical assumptions.
- This object is not optimal; however, it will work with any or no IWaitable
- On systems where context switches are expensive, this object should be avoided at all costs
This object depends on the synchronization of primitives within our abstraction layer rather than the OS's implementation of condition variables.
- 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);
}
\ No newline at end of file
diff --git a/Include/Aurora/Threading/Primitives/SOOPrimitives.hpp b/Include/Aurora/Threading/Primitives/SOOPrimitives.hpp
index 63ed8e4c..9675dd7e 100644
--- a/Include/Aurora/Threading/Primitives/SOOPrimitives.hpp
+++ b/Include/Aurora/Threading/Primitives/SOOPrimitives.hpp
@@ -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(8 + kPrimitiveSizeSemaphore + 4, sizeof(AuUInt));
+
struct AUKN_SYM HyperWaitable : IWaitable
{
auline inline void Lock() final override
diff --git a/Source/Threading/Primitives/AuConditionEx.cpp b/Source/Threading/Primitives/AuConditionEx.cpp
index 47374db9..54a97585 100644
--- a/Source/Threading/Primitives/AuConditionEx.cpp
+++ b/Source/Threading/Primitives/AuConditionEx.cpp
@@ -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(pCVEx);
}
+
+ AUROXTL_INTERFACE_SOO_SRC_EX(AURORA_SYMBOL_EXPORT, FlexibleConditionVariable, SemaphoreConditionVariableImpl)
}
\ No newline at end of file