AuroraRuntime/Source/IO/Loop/LSWin32.NT.cpp

56 lines
1.2 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: LSWin32.NT.cpp
Date: 2021-10-2
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "LSWin32.NT.hpp"
#if !defined(PM_NOREMOVE)
#define PM_NOREMOVE 0x0000
#endif
namespace Aurora::IO::Loop
{
bool Win32Dummy::IsSignaled()
{
MSG askers;
return pPeekMessageW &&
pPeekMessageW(&askers, 0, 0, 0, PM_NOREMOVE);
}
bool Win32Dummy::WaitOn(AuUInt32 timeout)
{
// TODO: Close
static HANDLE kAlwaysOffMutex = CreateEventW(nullptr, true, false, nullptr);
if (!pMsgWaitForMultipleObjects)
{
return false;
}
#if defined(QS_ALLEVENTS)
return pMsgWaitForMultipleObjects(0, &kAlwaysOffMutex, false, timeout ? timeout : INFINITE, QS_ALLEVENTS) == WAIT_OBJECT_0 + 1;
#else
return false;
#endif
}
ELoopSource Win32Dummy::GetType()
{
return ELoopSource::eSourceWin32;
}
AUKN_SYM AuSPtr<ILoopSource> NewLSWin32Source(bool pumping)
{
AuSPtr<ILoopSource> ret;
if (!(ret = AuMakeShared<Win32Dummy>(pumping)))
{
return {};
}
return ret;
}
}