AuroraRuntime/Source/Loop/LSEvent.NT.cpp
2022-04-16 19:26:01 +01:00

71 lines
1.5 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: LSEvent.NT.cpp
Date: 2021-10-1
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "LSEvent.hpp"
namespace Aurora::Loop
{
LSEvent::LSEvent(HANDLE h) : LSHandle(AuUInt(h))
{
}
LSEvent::LSEvent(bool triggered, bool atomicRelease, bool permitMultipleTriggers) : LSHandle((AuUInt)::CreateEventW(NULL, !atomicRelease, triggered, NULL))
{
}
LSEvent::~LSEvent()
{
auto handle = reinterpret_cast<HANDLE>(this->handle);
AuWin32CloseHandle(handle);
this->handle = kInvalidHandle;
}
bool LSEvent::Set()
{
return SetEvent(reinterpret_cast<HANDLE>(this->handle));
}
bool LSEvent::Reset()
{
return ResetEvent(reinterpret_cast<HANDLE>(this->handle));
}
bool LSEvent::IsSignaled()
{
return LSHandle::IsSignaled();
}
bool LSEvent::WaitOn(AuUInt32 timeout)
{
return LSHandle::WaitOn(timeout);
}
ELoopSource LSEvent::GetType()
{
return ELoopSource::eSourceEvent;
}
AUKN_SYM AuSPtr<ILSEvent> NewLSEvent(bool triggerd, bool atomicRelease, bool permitMultipleTriggers)
{
AuSPtr<LSEvent> ret;
if (!(ret = AuMakeShared<LSEvent>(triggerd, atomicRelease, permitMultipleTriggers)))
{
return {};
}
if (!ret->HasValidHandle())
{
return {};
}
return ret;
}
}