57 lines
1.4 KiB
C++
57 lines
1.4 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 {};
|
|
AuUInt two {};
|
|
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
|
|
{
|
|
#if defined(AURORA_IS_POSIX_DERIVED)
|
|
auto handles = this->GetHandles();
|
|
auto handlesRw = this->GetWriteHandles();
|
|
val = this->WaitForAtleastOne(handles, handlesRw, one, two);
|
|
if (one == -1) one = two;
|
|
#else
|
|
auto handles = this->GetHandles();
|
|
val = this->WaitForAtleastOne(handles, one);
|
|
#endif
|
|
|
|
if (val)
|
|
{
|
|
val = this->OnTrigger(one);
|
|
}
|
|
}
|
|
|
|
this->OnFinishSleep();
|
|
return val;
|
|
}
|
|
}
|