2021-06-27 21:25:29 +00:00
/***
Copyright ( C ) 2021 J Reece Wilson ( a / k / a " Reece " ) . All rights reserved .
File : Event . hpp
Date : 2021 - 6 - 9
Author : Reece
* * */
# pragma once
namespace Aurora : : Threading : : Primitives
{
/**
Event synchronization primitive
*/
2023-01-15 06:05:22 +00:00
struct IEvent : IWaitable
2021-06-27 21:25:29 +00:00
{
2023-01-15 06:05:22 +00:00
// Unlike the other types, unlock is always a nop. It makes sense the caller to not automatically reset an event, contrary to `::Lock(); work; ::Unlock();`
// Ordinarily, we would expect the thread responsible for work processing to ::Lock/::Unlock (maybe ::Reset()), and the dispatching thread to ::Reset and ::Set.
2021-06-27 21:25:29 +00:00
inline void Wait ( )
{
Lock ( ) ;
}
inline void Wait ( AuUInt32 ms )
{
2023-04-03 07:21:44 +00:00
LockMS ( ms ) ;
2021-06-27 21:25:29 +00:00
}
2023-09-10 13:00:18 +00:00
virtual void Reset ( ) = 0 ;
virtual void Set ( ) = 0 ;
virtual bool TrySet ( ) = 0 ; // returns false on bPermitMultipleTriggers volation
2021-06-27 21:25:29 +00:00
} ;
2023-08-16 08:47:54 +00:00
AUKN_SHARED_SOO2_NCM ( Event , IEvent , kPrimitiveSizeEvent ,
( ( bool , bTriggered ) , ( bool , bAtomicRelease ) , ( bool , bPermitMultipleTriggers ) ) ,
bool bInitiallyTriggerd = false ,
bool bAtomicRelease = true ,
bool bPermitMultipleTriggers = false ) ;
2021-06-27 21:25:29 +00:00
}