AuroraRuntime/Source/IO/Loop/LSLocalEvent.hpp

64 lines
1.4 KiB
C++

/***
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: LSLocalEvent.hpp
Date: 2023-10-21
Author: Reece
***/
#pragma once
#include "LSSemaphore.hpp"
namespace Aurora::IO::Loop
{
struct LSLocalEvent : LSSemaphore, ILSEvent
{
LSLocalEvent();
~LSLocalEvent();
bool TryInit(bool bTriggered, bool bAtomicRelease, bool bPermitMultipleTriggers);
bool IsSignaled() override;
bool WaitOn(AuUInt32 timeout) override;
ELoopSource GetType() override;
bool Set() override;
bool Reset() override;
virtual bool OnTrigger(AuUInt handle) override;
bool TryTakeNoSpin();
bool TryTakeSpin();
bool TryTake();
bool TryTakeWaitMS(AuUInt32 timeout);
bool IsSignaledNoSpinIfUserland() override;
void OnPresleep() override;
void OnFinishSleep() override;
union EventBits
{
struct
{
AuUInt8 bAtomicRelease : 1;
AuUInt8 bPermitMultipleTriggers : 1;
AuUInt8 bTriggered : 1;
};
AuUInt32 state;
};
union
{
struct
{
AuUInt8 bAtomicRelease_ : 1;
AuUInt8 bPermitMultipleTriggers_ : 1;
AuUInt8 bTriggered_ : 1;
};
AuUInt32 state_;
};
AuUInt32 uApproxSleepCount {};
};
}