Compare commits

...

2 Commits

3 changed files with 16 additions and 15 deletions

View File

@ -402,7 +402,7 @@ namespace Aurora::Memory
MemoryView Clone(Heap *pHeap, AuUInt32 uAlignment = alignof(double)) const
{
auto uLength = this->uLength;
auto pData = detail::AllocateArray(uLength, uAlignment);
auto pData = detail::AllocateArray(pHeap, uLength, uAlignment);
if (!pData)
{
return {};

View File

@ -19,20 +19,20 @@ namespace Aurora::Threading::Primitives
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
struct IFlexibleConditionVariable
{
virtual void WaitForSignal() = 0;
virtual void WaitForSignal(const AuSPtr<IWaitable> &pWaitable) = 0;
virtual void WaitForSignal(IWaitable *pWaitable) = 0;
virtual bool WaitForSignalNS(AuUInt64 uRelativeNanoseconds) = 0;
virtual bool WaitForSignalNS(const AuSPtr<IWaitable> &pWaitable, AuUInt64 uRelativeNanoseconds) = 0;
virtual bool WaitForSignalNS(IWaitable *pWaitable, AuUInt64 uRelativeNanoseconds) = 0;
virtual bool WaitForSignalAbsNS(AuUInt64 uAbsNanoseconds) = 0;
virtual bool WaitForSignalAbsNS(const AuSPtr<IWaitable> &pWaitable, AuUInt64 uAbsNanoseconds) = 0;
virtual bool WaitForSignalAbsNS(IWaitable *pWaitable, AuUInt64 uAbsNanoseconds) = 0;
virtual void Broadcast() = 0;
virtual void Signal() = 0;
};
AUKN_SHARED_SOO_NCM(FlexibleConditionVariable, ConditionEx, kPrimitiveSizeSemaphoreCV);
AUKN_SHARED_SOO_NCM(FlexibleConditionVariable, IFlexibleConditionVariable, kPrimitiveSizeSemaphoreCV);
}

View File

@ -12,18 +12,19 @@
namespace Aurora::Threading::Primitives
{
struct SemaphoreConditionVariableImpl : ConditionEx
struct SemaphoreConditionVariableImpl :
IFlexibleConditionVariable
{
SemaphoreConditionVariableImpl();
void WaitForSignal(const AuSPtr<IWaitable> &pWaitable) override;
void WaitForSignal(IWaitable *pWaitable) override;
void WaitForSignal() override;
bool WaitForSignalNS(AuUInt64 uRelativeNanoseconds) override;
bool WaitForSignalNS(const AuSPtr<IWaitable> &waitable, AuUInt64 uRelativeNanoseconds) override;
bool WaitForSignalNS(IWaitable *pWaitable, AuUInt64 uRelativeNanoseconds) override;
bool WaitForSignalAbsNS(AuUInt64 uAbsNanoseconds) override;
bool WaitForSignalAbsNS(const AuSPtr<IWaitable> &pWaitable, AuUInt64 uAbsNanoseconds) override;
bool WaitForSignalAbsNS(IWaitable *pWaitable, AuUInt64 uAbsNanoseconds) override;
void Signal() override;
void Broadcast() override;
@ -45,7 +46,7 @@ namespace Aurora::Threading::Primitives
return WaitForSignalNS(nullptr, uRelativeNanoseconds);
}
bool SemaphoreConditionVariableImpl::WaitForSignalAbsNS(const AuSPtr<IWaitable> &pWaitable,
bool SemaphoreConditionVariableImpl::WaitForSignalAbsNS(IWaitable *pWaitable,
AuUInt64 uNanoseconds)
{
AuAtomicAdd(&this->uWaiters_, 1u);
@ -81,14 +82,14 @@ namespace Aurora::Threading::Primitives
return bSuccess;
}
bool SemaphoreConditionVariableImpl::WaitForSignalNS(const AuSPtr<IWaitable> &pWaitable,
bool SemaphoreConditionVariableImpl::WaitForSignalNS(IWaitable *pWaitable,
AuUInt64 uAbsNanoseconds)
{
return this->WaitForSignalAbsNS(pWaitable,
uAbsNanoseconds ? AuTime::SteadyClockNS() + uAbsNanoseconds : 0);
}
void SemaphoreConditionVariableImpl::WaitForSignal(const AuSPtr<IWaitable> &pWaitable)
void SemaphoreConditionVariableImpl::WaitForSignal(IWaitable *pWaitable)
{
AuAtomicAdd(&this->uWaiters_, 1u);
@ -163,12 +164,12 @@ namespace Aurora::Threading::Primitives
}
}
AUKN_SYM ConditionEx *FlexibleConditionVariableNew()
AUKN_SYM IFlexibleConditionVariable *FlexibleConditionVariableNew()
{
return _new SemaphoreConditionVariableImpl();
}
AUKN_SYM void FlexibleConditionVariableRelease(ConditionEx *pCVEx)
AUKN_SYM void FlexibleConditionVariableRelease(IFlexibleConditionVariable *pCVEx)
{
AuSafeDelete<SemaphoreConditionVariableImpl *>(pCVEx);
}