2022-05-13 18:54:26 +00:00
|
|
|
/***
|
|
|
|
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 milliseconds, bool waitEntireFrame)
|
|
|
|
{
|
|
|
|
bool bHit {};
|
|
|
|
AuUInt32 targetTime = milliseconds ? AuTime::CurrentClockNS() + AuNSToMS<AuUInt64>(milliseconds) : 0;
|
|
|
|
|
|
|
|
if (!milliseconds)
|
|
|
|
{
|
|
|
|
waitEntireFrame = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
AuUInt32 sleep;
|
|
|
|
|
|
|
|
if (targetTime)
|
|
|
|
{
|
|
|
|
auto now = AuTime::CurrentClockNS();
|
|
|
|
if (now >= targetTime)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
sleep = AuNSToMS<AuUInt32>(now - targetTime);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sleep = 0;
|
|
|
|
}
|
|
|
|
|
2022-06-11 23:01:27 +00:00
|
|
|
if (!UNIX::LinuxOverlappedPoll(sleep))
|
2022-05-13 18:54:26 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bHit = true;
|
|
|
|
|
|
|
|
if (!waitEntireFrame)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bHit;
|
|
|
|
}
|
2022-06-12 13:53:35 +00:00
|
|
|
|
|
|
|
AUKN_SYM bool IOYield()
|
|
|
|
{
|
|
|
|
AuLogWarn("TODO");
|
|
|
|
return false;
|
|
|
|
}
|
2022-05-13 18:54:26 +00:00
|
|
|
}
|