AuroraRuntime/Source/IO/IOSleep.NT.cpp
Reece 44108a322e 2/3 of the IO update (very early implementation)
[+] TTYConsole::GetPaddingTopOfLog,GetPaddingHeadOfLog,GetPaddingTopOfLog [+ set variants]
[+] IO::IOYield()
[+] IO::IAsyncTransaction::Failed,GetOSErrorCode()
[+] IByteBufferStreamPair
[+] IIOBufferedInterceptor
[+] IIOBufferedProcessor
[+] IIOEventListener
[+] IIOPipeEventListener
[+] IIOProcessorEventListener
[+] IIOProcessorManualInvoker
[+] IIOWaitableIOLoopSource
[+] IIOWaitableIOTimer
[+] IIOWaitableItem
[+] IIOWaitableTickLimiter
[+] IOAdapterAsyncStream
[+] IOAdapterByteBuffer
[+] IOAdapterCompression
[+] IOAdapterSeeking
[*] Cleanup CpuInfo.Linux.cpp
[*] Fixup async threadpool some more
[*] LSTimer.NT.cpp updates timer object on tick state update, akin to Linux
2022-06-12 00:01:27 +01:00

66 lines
1.4 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: IOSleep.NT.hpp
Date: 2022-5-13
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "IO.hpp"
#include "IOSleep.NT.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 = INFINITE;
}
if (SleepEx(sleep, true) != WAIT_IO_COMPLETION)
{
continue;
}
while (SleepEx(0, true) == WAIT_IO_COMPLETION) ;
bHit = true;
if (!waitEntireFrame)
{
break;
}
}
return bHit;
}
AUKN_SYM bool IOYield()
{
return SleepEx(0, true) == WAIT_IO_COMPLETION;
}
}