AuroraRuntime/Source/IO/AuIOSleep.Linux.cpp
Reece 4e6f116925 [*] Refactor
[+] IProcessSectionView::GetStart
[+] IProcessSectionView::GetEnd
2022-12-17 20:14:19 +00:00

64 lines
1.3 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuIOSleep.Linux.cpp
Date: 2022-5-13
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "IO.hpp"
#include "AuIOSleep.Linux.hpp"
#include "UNIX/IOSubmit.Linux.hpp"
namespace Aurora::IO
{
AUKN_SYM bool WaitFor(AuUInt32 dwMilliseconds, bool bWaitEntireFrame)
{
bool bHit {};
AuUInt32 targetTime = dwMilliseconds ? AuTime::SteadyClockNS() + AuNSToMS<AuUInt64>(dwMilliseconds) : 0;
if (!dwMilliseconds)
{
bWaitEntireFrame = false;
}
while (true)
{
AuUInt32 dwSleep;
if (targetTime)
{
auto now = AuTime::SteadyClockNS();
if (now >= targetTime)
{
break;
}
dwSleep = AuNSToMS<AuUInt32>(now - targetTime);
}
else
{
dwSleep = 0;
}
if (!UNIX::LinuxOverlappedPoll(dwSleep))
{
continue;
}
bHit = true;
if (!bWaitEntireFrame)
{
break;
}
}
return bHit;
}
AUKN_SYM bool IOYield()
{
return UNIX::LinuxOverlappedYield();
}
}