AuroraRuntime/Source/Loop/WaitSingleBase.cpp

48 lines
1.1 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: WaitSingle.Generic.cpp
Date: 2021-10-2
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "WaitSingleBase.hpp"
namespace Aurora::Loop
{
bool WaitSingleBase::IsSignaled()
{
bool val {};
AuUInt one {};
this->OnPresleep();
if (this->Singular())
{
#if defined(AURORA_IS_POSIX_DERIVED)
auto handle = this->GetHandle();
auto handleRw = this->GetWriteHandle();
val = this->WaitForOne(handle, handleRw);
#else
auto handle = this->GetHandle();
val = this->WaitForOne(handle);
#endif
if (val)
{
val = this->OnTrigger(handle);
}
}
else
{
auto handles = this->GetHandles();
val = WaitForAtleastOne(handles, one);
if (val)
{
val = this->OnTrigger(one);
}
}
this->OnFinishSleep();
return val;
}
}