2021-10-03 12:47:16 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: WaitSingle.NT.cpp
|
|
|
|
Date: 2021-10-1
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#include <Source/RuntimeInternal.hpp>
|
|
|
|
#include "WaitSingle.hpp"
|
|
|
|
|
|
|
|
namespace Aurora::Loop
|
|
|
|
{
|
|
|
|
bool WaitSingleGeneric::WaitForAtleastOne(const AuList<AuUInt> &handles, AuUInt &one)
|
|
|
|
{
|
|
|
|
if (handles.empty())
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (handles.size() == 1)
|
|
|
|
{
|
2022-01-24 18:37:06 +00:00
|
|
|
return WaitForSingleObjectEx(reinterpret_cast<HANDLE>(handles.at(0)), 0, true) == WAIT_OBJECT_0;
|
2021-10-03 12:47:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AuList<HANDLE> ntHandles;
|
|
|
|
ntHandles.reserve(handles.size());
|
|
|
|
for (const auto &handle : handles)
|
|
|
|
{
|
|
|
|
ntHandles.push_back(reinterpret_cast<HANDLE>(handle));
|
|
|
|
}
|
2022-01-24 18:37:06 +00:00
|
|
|
return WaitForMultipleObjectsEx(ntHandles.size(), ntHandles.data(), false, 0, true) >= WAIT_OBJECT_0;
|
2021-10-03 12:47:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WaitSingleGeneric::OnPresleep()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void WaitSingleGeneric::OnFinishSleep()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ELoopSource WaitSingleGeneric::GetType()
|
|
|
|
{
|
|
|
|
return ELoopSource::eSourceInternalReserved1;
|
|
|
|
}
|
|
|
|
}
|