/* ======================================== Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. ======================================== */ #include /// ================================================================================ /// @brief SoftwareTimer class, meant to be generic. ///! @author Amlal El Mahrouss (amlal@nekernel.org) /// ================================================================================ using namespace Kernel; SoftwareTimer::SoftwareTimer(Int64 seconds) : fWaitFor(seconds) { fDigitalTimer = new UIntPtr(); MUST_PASS(fDigitalTimer); } SoftwareTimer::~SoftwareTimer() { delete fDigitalTimer; fDigitalTimer = nullptr; fWaitFor = 0; } BOOL SoftwareTimer::Wait() noexcept { if (fWaitFor < 1) return NO; while (*fDigitalTimer < (*fDigitalTimer + fWaitFor)) { ++(*fDigitalTimer); } return YES; }