/*** Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: LSEvent.NT.cpp Date: 2021-10-1 Author: Reece ***/ #include #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(this->handle); AuWin32CloseHandle(handle); this->handle = kInvalidHandle; } bool LSEvent::Set() { return SetEvent(reinterpret_cast(this->handle)); } bool LSEvent::Reset() { return ResetEvent(reinterpret_cast(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 NewLSEvent(bool triggerd, bool atomicRelease, bool permitMultipleTriggers) { AuSPtr ret; if (!(ret = AuMakeShared(triggerd, atomicRelease, permitMultipleTriggers))) { return {}; } if (!ret->HasValidHandle()) { return {}; } return ret; } }