AuroraRuntime/Include/Aurora/Threading/Primitives/Event.hpp
2021-09-13 21:11:12 +01:00

38 lines
1.2 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
*/
class IEvent : public IWaitable
{
public:
// Unlike the other types, unlock is always a nop. It makes sense for the schedular or any other caller to not automatically reset an event, contrary to `::Lock(); work; ::Unlock();`
// Ordinarily, we would expect the thread responsible for dispatching work to Unlock, and the caller Reset, at least in principle. This, however, does not account for reusability.
// It makes sense to implement reset-on-worker-acknowledge, permit-multiple-triggers (a kind of countless semaphores), and any combination thereof
// Besides from atomicRelease, Reset and Set is on your watch.
inline void Wait()
{
Lock();
}
inline void Wait(AuUInt32 ms)
{
Lock(ms);
}
virtual void Reset() = 0;
virtual void Set() = 0;
};
AUKN_SHARED_API(Event, IEvent, bool triggerd = false, bool atomicRelease = true, bool permitMultipleTriggers = false);
}