AuroraRuntime/Source/Threading/Primitives/AuEvent.hpp

47 lines
1.2 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuEvent.hpp
Date: 2021-6-12
Author: Reece
***/
#pragma once
#include "AuConditionVariable.Generic.hpp"
#include "AuConditionMutex.Generic.hpp"
namespace Aurora::Threading::Primitives
{
struct EventImpl final : IEvent
{
EventImpl(bool bTriggered, bool bAtomicRelease, bool bPermitMultipleTriggers);
~EventImpl();
bool Init();
bool LockMS(AuUInt64 timeout /*=0*/) override;
bool LockNS(AuUInt64 timeout /*=0*/) override;
bool TryLock() override;
void Reset() override;
void Set() override;
bool HasOSHandle(AuMach &mach) override;
bool HasLockImplementation() override;
void Lock() override;
void Unlock() override;
private:
bool AtomicIsEventSetLogic();
ConditionMutexInternal mutex_; // must come first
ConditionVariableInternal condition_;
#if 0
const bool bAtomicRelease_ {};
const bool bPermitMultipleTriggers_ {};
bool bTriggered_ {};
#else
AuUInt8 bAtomicRelease_ : 1;
AuUInt8 bPermitMultipleTriggers_ : 1;
AuUInt8 bTriggered_ : 1;
#endif
};
}