From d48cbe75ef29a9c67c9d176bf58e56ea6448fb9e Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 21 Oct 2024 20:23:36 +0200 Subject: IMP: Major refactor of header and source files extensions. Signed-off-by: Amlal El Mahrouss --- dev/zka/src/Timer.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 dev/zka/src/Timer.cc (limited to 'dev/zka/src/Timer.cc') diff --git a/dev/zka/src/Timer.cc b/dev/zka/src/Timer.cc new file mode 100644 index 00000000..e7ad488a --- /dev/null +++ b/dev/zka/src/Timer.cc @@ -0,0 +1,47 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#include + +///! BUGS: 0 +///! @file Timer.cxx +///! @brief Software Timer implementation + +using namespace Kernel; + +/// @brief Unimplemented as it is an interface. +Int32 TimerInterface::Wait() noexcept +{ + return kErrorUnimplemented; +} + +/// @brief SoftwareTimer class, meant to be generic. + +SoftwareTimer::SoftwareTimer(Int64 seconds) + : fWaitFor(seconds) +{ + fDigitalTimer = new IntPtr(); + MUST_PASS(fDigitalTimer); +} + +SoftwareTimer::~SoftwareTimer() +{ + delete fDigitalTimer; + fWaitFor = 0; +} + +Int32 SoftwareTimer::Wait() noexcept +{ + if (fWaitFor < 1) + return -1; + + while (*fDigitalTimer < (*fDigitalTimer + fWaitFor)) + { + ++(*fDigitalTimer); + } + + return 0; +} -- cgit v1.2.3