summaryrefslogtreecommitdiffhomepage
path: root/dev/zka/src/Timer.cc
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-10-21 20:23:36 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-10-21 20:23:36 +0200
commitd48cbe75ef29a9c67c9d176bf58e56ea6448fb9e (patch)
tree89cbd6b7e23802f92bf3158868f4dc33c088e516 /dev/zka/src/Timer.cc
parent21b3da78f806d6765f9dffa6a84c21346f171cee (diff)
IMP: Major refactor of header and source files extensions.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/zka/src/Timer.cc')
-rw-r--r--dev/zka/src/Timer.cc47
1 files changed, 47 insertions, 0 deletions
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 <KernelKit/Timer.h>
+
+///! 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;
+}