[*] Begin using SOO No-Move and No-Copy macros

This commit is contained in:
Reece Wilson 2023-08-16 09:47:54 +01:00
parent 9502930c1b
commit 1c2673fc0a
10 changed files with 47 additions and 18 deletions

View File

@ -133,5 +133,5 @@ namespace Aurora::IO
virtual bool IsPipe() = 0; virtual bool IsPipe() = 0;
}; };
AUKN_SHARED_SOO(IOHandle, IIOHandle, 256); AUKN_SHARED_SOO_NC(IOHandle, IIOHandle, 256);
} }

View File

@ -33,7 +33,11 @@
#define AUKN_SHARED_API(name, type, ...) AU_SHARED_API_EX(AUKN_SYM, name, type, ## __VA_ARGS__) #define AUKN_SHARED_API(name, type, ...) AU_SHARED_API_EX(AUKN_SYM, name, type, ## __VA_ARGS__)
#define AUKN_SHARED_SOO(name, type, size, ...) AUKN_SHARED_API(name, type, ## __VA_ARGS__) AUROXTL_INTERFACE_SOO_HDR_EX(AUKN_SYM, name, type, size) #define AUKN_SHARED_SOO(name, type, size, ...) AUKN_SHARED_API(name, type, ## __VA_ARGS__) AUROXTL_INTERFACE_SOO_HDR_EX(AUKN_SYM, name, type, size)
#define AUKN_SHARED_SOO_NC(name, type, size, ...) AUKN_SHARED_API(name, type, ## __VA_ARGS__) AUROXTL_INTERFACE_SOO_HDR_EX_NC(AUKN_SYM, name, type, size)
#define AUKN_SHARED_SOO_NCM(name, type, size, ...) AUKN_SHARED_API(name, type, ## __VA_ARGS__) AUROXTL_INTERFACE_SOO_HDR_EX_NCM(AUKN_SYM, name, type, size)
#define AUKN_SHARED_SOO2(name, type, size, ctrs, ...) AUKN_SHARED_API(name, type, ## __VA_ARGS__) AUROXTL_INTERFACE_SOO_HDR_EX(AUKN_SYM, name, type, size, AU_STRIP_BRACKETS(ctrs)) #define AUKN_SHARED_SOO2(name, type, size, ctrs, ...) AUKN_SHARED_API(name, type, ## __VA_ARGS__) AUROXTL_INTERFACE_SOO_HDR_EX(AUKN_SYM, name, type, size, AU_STRIP_BRACKETS(ctrs))
#define AUKN_SHARED_SOO2_NC(name, type, size, ctrs, ...) AUKN_SHARED_API(name, type, ## __VA_ARGS__) AUROXTL_INTERFACE_SOO_HDR_EX_NC(AUKN_SYM, name, type, size, AU_STRIP_BRACKETS(ctrs))
#define AUKN_SHARED_SOO2_NCM(name, type, size, ctrs, ...) AUKN_SHARED_API(name, type, ## __VA_ARGS__) AUROXTL_INTERFACE_SOO_HDR_EX_NCM(AUKN_SYM, name, type, size, AU_STRIP_BRACKETS(ctrs))
#if defined(_AURORA_RUNTIME_BUILD_API_INTERFACES) #if defined(_AURORA_RUNTIME_BUILD_API_INTERFACES)
#define AUKN_INTERFACE AUI_INTERFACE_IMPL #define AUKN_INTERFACE AUI_INTERFACE_IMPL

View File

@ -29,5 +29,5 @@ namespace Aurora::Threading::Primitives
virtual void Signal() = 0; virtual void Signal() = 0;
}; };
AUKN_SHARED_SOO(FlexibleConditionVariable, ConditionEx, kPrimitiveSizeSemaphoreCV); AUKN_SHARED_SOO_NCM(FlexibleConditionVariable, ConditionEx, kPrimitiveSizeSemaphoreCV);
} }

View File

@ -21,5 +21,5 @@ namespace Aurora::Threading::Primitives
virtual void Unlock() = 0; virtual void Unlock() = 0;
}; };
AUKN_SHARED_SOO(ConditionMutex, IConditionMutex, kPrimitiveSizeCondMutex); AUKN_SHARED_SOO_NCM(ConditionMutex, IConditionMutex, kPrimitiveSizeCondMutex);
} }

View File

@ -18,14 +18,38 @@ namespace Aurora::Threading::Primitives
*/ */
struct IConditionVariable struct IConditionVariable
{ {
/**
* @brief Returns the mutex the condvar was bound to
*/
virtual AuSPtr<IConditionMutex> GetMutex() = 0; virtual AuSPtr<IConditionMutex> GetMutex() = 0;
/**
* @brief
* @param uTimeoutMS timeout in milliseconds or zero for an indefinite amount of time
* @return
*/
virtual bool WaitForSignal(AuUInt32 uTimeoutMS = 0) = 0; virtual bool WaitForSignal(AuUInt32 uTimeoutMS = 0) = 0;
/**
* @brief
* @param uTimeoutMS timeout in nanoseconds or zero for an indefinite amount of time
* @return
*/
virtual bool WaitForSignalNS(AuUInt64 uTimeoutNS = 0) = 0; virtual bool WaitForSignalNS(AuUInt64 uTimeoutNS = 0) = 0;
/**
* @brief Wakes the count of currently sleeping threads without guaranteed respect for ordering.
* Assuming correctness of your mutex paths, this will wake all threads up-to your everyone-be-alert condition.
*/
virtual void Broadcast() = 0; virtual void Broadcast() = 0;
/**
* @brief Schedules a single thread for wake up without guaranteed respect for ordering.
*/
virtual void Signal() = 0; virtual void Signal() = 0;
}; };
AUKN_SHARED_SOO2(ConditionVariable, IConditionVariable, kPrimitiveSizeCond, AUKN_SHARED_SOO2_NCM(ConditionVariable, IConditionVariable, kPrimitiveSizeCond,
((const AuSPtr<IConditionMutex>&, pMutex)), ((const AuSPtr<IConditionMutex>&, pMutex)),
const AuSPtr<IConditionMutex> &mutex); const AuSPtr<IConditionMutex> &mutex);
} }

View File

@ -9,5 +9,5 @@
namespace Aurora::Threading::Primitives namespace Aurora::Threading::Primitives
{ {
AUKN_SHARED_SOO(CriticalSection, IWaitable, kPrimitiveSizeCS); AUKN_SHARED_SOO_NCM(CriticalSection, IWaitable, kPrimitiveSizeCS);
} }

View File

@ -31,9 +31,9 @@ namespace Aurora::Threading::Primitives
virtual void Set() = 0; virtual void Set() = 0;
}; };
AUKN_SHARED_SOO2(Event, IEvent, kPrimitiveSizeEvent, AUKN_SHARED_SOO2_NCM(Event, IEvent, kPrimitiveSizeEvent,
((bool, bTriggered), (bool, bAtomicRelease), (bool, bPermitMultipleTriggers)), ((bool, bTriggered), (bool, bAtomicRelease), (bool, bPermitMultipleTriggers)),
bool bInitiallyTriggerd = false, bool bInitiallyTriggerd = false,
bool bAtomicRelease = true, bool bAtomicRelease = true,
bool bPermitMultipleTriggers = false); bool bPermitMultipleTriggers = false);
} }

View File

@ -9,5 +9,5 @@
namespace Aurora::Threading::Primitives namespace Aurora::Threading::Primitives
{ {
AUKN_SHARED_SOO(Mutex, IHyperWaitable, kPrimitiveSizeMutex); AUKN_SHARED_SOO_NCM(Mutex, IHyperWaitable, kPrimitiveSizeMutex);
} }

View File

@ -27,23 +27,24 @@ namespace Aurora::Threading::Primitives
/** /**
* @brief Allows for read-to-write upgrades when the decision to esclate is made based upon a shared resource * @brief Allows for read-to-write upgrades when the decision to esclate is made based upon a shared resource
* which would be lost by unlocking and relocking in exclusive mode * which would be lost by unlocking and relocking in exclusive mode.
* You must be careful to consider how this is used to prevent dead-locks
* @param timeout * @param timeout
* @return * @return
*/ */
virtual bool UpgradeReadToWrite(AuUInt64 timeout) = 0; virtual bool UpgradeReadToWrite(AuUInt64 timeout) = 0;
/** /**
* @brief Reverses UpgradeReadToWrite. Helps maintain AU_TRY_LOCK lock guards. * @brief Reverses UpgradeReadToWrite.
* @return * @return
*/ */
virtual bool DowngradeWriteToRead() = 0; virtual bool DowngradeWriteToRead() = 0;
}; };
/// Allows AsReadable entrancy as AsWritable lock /// Allows AsReadable entrancy as AsWritable lock
AUKN_SHARED_SOO(RWLock, IRWLock, kPrimitiveSizeRWLock); AUKN_SHARED_SOO_NCM(RWLock, IRWLock, kPrimitiveSizeRWLock);
/// Allows AsWritable reentrancy, and allows AsReadable entrancy as AsWritable lock /// Allows AsWritable reentrancy, and allows AsReadable entrancy as AsWritable lock
AUKN_SHARED_SOO(RWRenterableLock, IRWLock, kPrimitiveSizeRWLock); AUKN_SHARED_SOO_NCM(RWRenterableLock, IRWLock, kPrimitiveSizeRWLock);
} }

View File

@ -14,5 +14,5 @@ namespace Aurora::Threading::Primitives
virtual void Unlock(long count) = 0; virtual void Unlock(long count) = 0;
}; };
AUKN_SHARED_SOO(Semaphore, ISemaphore, kPrimitiveSizeSemaphore, int iInitialCount = 0); AUKN_SHARED_SOO_NCM(Semaphore, ISemaphore, kPrimitiveSizeSemaphore, int iInitialCount = 0);
} }