AuroraRuntime/Source/Threading/Primitives/Event.hpp
2022-02-19 13:21:34 +00:00

38 lines
944 B
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Event.hpp
Date: 2021-6-12
Author: Reece
***/
#pragma once
namespace Aurora::Threading::Primitives
{
class EventImpl : public IEvent
{
public:
EventImpl(bool trigged, bool atomicRelease, bool permitMultipleTriggers);
~EventImpl();
bool Init();
bool Lock(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 AtomicIsEventSet();
const bool atomicRelease_{};
const bool permitMultipleTriggers_{};
ConditionMutexUnique_t mutex_;
ConditionVariableUnique_t condition_;
bool triggered_;
};
}