/*** Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: Sleep.cpp Date: 2021-6-12 Author: Reece ***/ #include #include "Sleep.hpp" #include "WaitFor.hpp" #if defined(AURORA_PLATFORM_LINUX) #include #endif namespace Aurora::Threading { AUKN_SYM void Sleep(AuUInt64 timeout) { #if defined(AURORA_PLATFORM_LINUX) || defined(AURORA_PLATFORM_ANDROID) usleep(timeout * 1000000); #elif defined(AURORA_PLATFORM_WIN32) ::Sleep(timeout); #else std::atomic value = false; BooleanWaitable waitable(value); WaitFor(&waitable, timeout); #endif } AUKN_SYM void SleepNs(AuUInt64 timeout) { #if defined(AURORA_PLATFORM_LINUX) || defined(AURORA_PLATFORM_ANDROID) usleep(timeout); #else YieldPollNs(true, timeout + Time::CurrentClockNS(), [=]() { return false; }); #endif } }