AuroraRuntime/Source/IO/IOSleep.Linux.cpp
Reece Wilson 267c2216b0 [+] UDP over socket API via existing INetSrvDatagram layer
(...missing send)
[+] AuIO::Buffer::ViewReader
[+] AuIO::Buffer::ViewSeekableReadable
[+] AuIO::Buffer::ViewWriter
[*] Clean up AuCompression
[*[ AuLog messages must always crunch for memory
[*] Various bug fixes
[*] Refactor+clean up
2022-12-12 23:50:05 +00:00

64 lines
1.3 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: IOSleep.Linux.cpp
Date: 2022-5-13
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "IO.hpp"
#include "IOSleep.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();
}
}