2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
2022-11-17 07:46:07 +00:00
|
|
|
File: AuEvent.hpp
|
2021-06-27 21:25:29 +00:00
|
|
|
Date: 2021-6-12
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
2022-12-29 00:02:56 +00:00
|
|
|
#include "AuConditionVariable.Generic.hpp"
|
|
|
|
#include "AuConditionMutex.Generic.hpp"
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
namespace Aurora::Threading::Primitives
|
|
|
|
{
|
2023-03-13 23:57:32 +00:00
|
|
|
struct EventImpl : IEvent
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2023-03-13 23:57:32 +00:00
|
|
|
EventImpl(bool bTriggered, bool bAtomicRelease, bool bPermitMultipleTriggers);
|
2021-06-27 21:25:29 +00:00
|
|
|
~EventImpl();
|
|
|
|
|
|
|
|
bool Init();
|
2023-04-03 07:21:44 +00:00
|
|
|
bool LockMS(AuUInt64 timeout /*=0*/) override;
|
2023-03-12 15:27:28 +00:00
|
|
|
bool LockNS(AuUInt64 timeout /*=0*/) override;
|
2021-06-27 21:25:29 +00:00
|
|
|
bool TryLock() override;
|
|
|
|
void Reset() override;
|
|
|
|
void Set() override;
|
|
|
|
bool HasOSHandle(AuMach &mach) override;
|
|
|
|
bool HasLockImplementation() override;
|
|
|
|
void Lock() override;
|
|
|
|
void Unlock() override;
|
|
|
|
|
|
|
|
private:
|
2023-03-13 23:57:32 +00:00
|
|
|
bool AtomicIsEventSetLogic();
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2023-03-17 15:40:15 +00:00
|
|
|
ConditionMutexImpl mutex_; // must come first
|
|
|
|
ConditionVariableImpl condition_;
|
|
|
|
|
|
|
|
#if 0
|
2023-03-13 23:57:32 +00:00
|
|
|
const bool bAtomicRelease_ {};
|
|
|
|
const bool bPermitMultipleTriggers_ {};
|
|
|
|
bool bTriggered_ {};
|
2023-03-17 15:40:15 +00:00
|
|
|
#else
|
|
|
|
AuUInt8 bAtomicRelease_ : 1;
|
|
|
|
AuUInt8 bPermitMultipleTriggers_ : 1;
|
|
|
|
AuUInt8 bTriggered_ : 1;
|
|
|
|
#endif
|
2021-06-27 21:25:29 +00:00
|
|
|
};
|
|
|
|
}
|