From c3e898d53ddc5b503e330922ff8ef4d8280db495 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Tue, 28 May 2024 19:28:08 +0100 Subject: [PATCH] [*] Redo d520b0ce with the lost semaphore copy described in the commit comment (wtf? did i stash something at the wrong time?) --- .../Threading/Waitables/FutexBarrier.hpp | 4 +++ .../Threading/Waitables/FutexCondWaitable.hpp | 10 ++----- .../Waitables/FutexSemaphoreWaitable.hpp | 14 +++++----- .../Threading/Waitables/FutexWaitable.hpp | 27 +++---------------- .../Aurora/Threading/Waitables/Waitables.hpp | 1 + Include/Aurora/Threading/Waitables/_.inl | 20 ++++++++++++++ 6 files changed, 39 insertions(+), 37 deletions(-) create mode 100644 Include/Aurora/Threading/Waitables/_.inl diff --git a/Include/Aurora/Threading/Waitables/FutexBarrier.hpp b/Include/Aurora/Threading/Waitables/FutexBarrier.hpp index 9e46eb36..21d6f7f9 100644 --- a/Include/Aurora/Threading/Waitables/FutexBarrier.hpp +++ b/Include/Aurora/Threading/Waitables/FutexBarrier.hpp @@ -12,6 +12,10 @@ namespace Aurora::Threading::Waitables { + /** + * Are you looking for AuFutexSemaphore::LockUntilExactlyEqualAbsNS timeline barriers/semaphores? + * This is a counting primitive of a binary signal state for syncing threads against work-group completion or a single work-group ready step. + */ struct FutexBarrier final { inline constexpr FutexBarrier(AuUInt32 uExpectThreads) : diff --git a/Include/Aurora/Threading/Waitables/FutexCondWaitable.hpp b/Include/Aurora/Threading/Waitables/FutexCondWaitable.hpp index 3037cf02..a8c1664c 100644 --- a/Include/Aurora/Threading/Waitables/FutexCondWaitable.hpp +++ b/Include/Aurora/Threading/Waitables/FutexCondWaitable.hpp @@ -9,19 +9,13 @@ #include "../WakeOnAddress.hpp" #include "../SpinTime.hpp" +#include "_.inl" namespace Aurora::Threading::Waitables { struct FutexCondWaitable final { - inline constexpr FutexCondWaitable() - {} - AU_MOVE(FutexCondWaitable) - inline constexpr FutexCondWaitable(const FutexCondWaitable &that) - { - // NOP - } - AU_OPERATOR_COPY(FutexCondWaitable) + AURT_WAITABLE_NULL_CTORS_DEF(FutexCondWaitable) template inline bool WaitNS(T pWaitable, AuUInt64 uRelativeNanoseconds) diff --git a/Include/Aurora/Threading/Waitables/FutexSemaphoreWaitable.hpp b/Include/Aurora/Threading/Waitables/FutexSemaphoreWaitable.hpp index 103ec3e4..5d5e95c6 100644 --- a/Include/Aurora/Threading/Waitables/FutexSemaphoreWaitable.hpp +++ b/Include/Aurora/Threading/Waitables/FutexSemaphoreWaitable.hpp @@ -9,6 +9,7 @@ #include "../WakeOnAddress.hpp" #include "../SpinTime.hpp" +#include "_.inl" namespace Aurora::Threading::Waitables { @@ -16,12 +17,13 @@ namespace Aurora::Threading::Waitables { inline constexpr FutexSemaphoreWaitable() {} - AU_MOVE(FutexSemaphoreWaitable) - inline constexpr FutexSemaphoreWaitable(const FutexSemaphoreWaitable &that) - { - // NOP - } - AU_OPERATOR_COPY(FutexSemaphoreWaitable) + inline constexpr FutexSemaphoreWaitable(const FutexSemaphoreWaitable & that) : + uAtomicState(that.uAtomicState) + { } + inline constexpr FutexSemaphoreWaitable(FutexSemaphoreWaitable &&that) : + uAtomicState(that.uAtomicState) + { } + AURT_WAITABLE_COPY_OPERATORS(FutexSemaphoreWaitable) inline auline bool TryLockNoSpin() { diff --git a/Include/Aurora/Threading/Waitables/FutexWaitable.hpp b/Include/Aurora/Threading/Waitables/FutexWaitable.hpp index 78c8e38c..849cb7de 100644 --- a/Include/Aurora/Threading/Waitables/FutexWaitable.hpp +++ b/Include/Aurora/Threading/Waitables/FutexWaitable.hpp @@ -9,19 +9,13 @@ #include "../WakeOnAddress.hpp" #include "../SpinTime.hpp" +#include "_.inl" namespace Aurora::Threading::Waitables { struct FutexWaitable final : IWaitable { - inline constexpr FutexWaitable() - {} - AU_MOVE(FutexWaitable) - inline constexpr FutexWaitable(const FutexWaitable &that) - { - // NOP - } - AU_OPERATOR_COPY(FutexWaitable) + AURT_WAITABLE_NULL_CTORS_DEF(FutexWaitable) inline bool TryLockNoSpin() { @@ -160,14 +154,7 @@ namespace Aurora::Threading::Waitables struct FutexWaitableNoVTblMovable final { - inline constexpr FutexWaitableNoVTblMovable() - {} - AU_MOVE(FutexWaitableNoVTblMovable) - inline constexpr FutexWaitableNoVTblMovable(const FutexWaitableNoVTblMovable &that) - { - // NOP - } - AU_OPERATOR_COPY(FutexWaitableNoVTblMovable) + AURT_WAITABLE_NULL_CTORS_DEF(FutexWaitableNoVTblMovable) inline bool TryLockNoSpin() { @@ -296,13 +283,7 @@ namespace Aurora::Threading::Waitables struct FutexWaitableNoVTblMovableSmallest final { - //AU_COPY_MOVE_DEF(FutexWaitableNoVTblMovableSmallest); - AU_MOVE(FutexWaitableNoVTblMovableSmallest) AU_DEF(FutexWaitableNoVTblMovableSmallest) - inline FutexWaitableNoVTblMovableSmallest(const FutexWaitableNoVTblMovableSmallest &that) - { - // NOP - } - AU_OPERATOR_COPY(FutexWaitableNoVTblMovableSmallest) + AURT_WAITABLE_NULL_CTORS_DEF(FutexWaitableNoVTblMovableSmallest) inline bool TryLockNoSpin() { diff --git a/Include/Aurora/Threading/Waitables/Waitables.hpp b/Include/Aurora/Threading/Waitables/Waitables.hpp index 99b47978..6cb40a58 100644 --- a/Include/Aurora/Threading/Waitables/Waitables.hpp +++ b/Include/Aurora/Threading/Waitables/Waitables.hpp @@ -7,6 +7,7 @@ ***/ #pragma once +#include "_.inl" #include "CBWaitable.hpp" #include "BooleanWaitable.hpp" #include "FutexWaitable.hpp" diff --git a/Include/Aurora/Threading/Waitables/_.inl b/Include/Aurora/Threading/Waitables/_.inl new file mode 100644 index 00000000..621a16d8 --- /dev/null +++ b/Include/Aurora/Threading/Waitables/_.inl @@ -0,0 +1,20 @@ +#pragma once + +#define AURT_WAITABLE_NULL_CTORS(Type) \ + inline constexpr Type(const Type &that) \ + { \ + } \ + inline constexpr Type(Type &&that) \ + { \ + } \ + AU_OPERATOR_COPY(Type) \ + AU_OPERATOR_MOVE(Type) + +#define AURT_WAITABLE_NULL_CTORS_DEF(Type) \ + AURT_WAITABLE_NULL_CTORS(Type) \ + inline constexpr Type() \ + { } + +#define AURT_WAITABLE_COPY_OPERATORS(Type) \ + AU_OPERATOR_COPY(Type) \ + AU_OPERATOR_MOVE(Type)