AuroraRuntime/Include/Aurora/Threading/Primitives/Event.hpp
Reece d755a9d651 [*] Massive perf boost by removing atomic and
[*] Refactor ambiguous IWaitable::Lock(timeoutMs) to LockMS to prevent final using collisions
2023-04-03 08:21:44 +01:00

39 lines
1.1 KiB
C++

/***
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
*/
struct IEvent : IWaitable
{
// 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.
inline void Wait()
{
Lock();
}
inline void Wait(AuUInt32 ms)
{
LockMS(ms);
}
virtual void Reset() = 0;
virtual void Set() = 0;
};
AUKN_SHARED_SOO2(Event, IEvent, kPrimitiveSizeEvent,
((bool, bTriggered), (bool, bAtomicRelease), (bool, bPermitMultipleTriggers)),
bool bInitiallyTriggerd = false,
bool bAtomicRelease = true,
bool bPermitMultipleTriggers = false);
}