From 37e364b2c6cc7487a1c888d256a73e5337bb7189 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 14 Jun 2023 00:50:34 +0100 Subject: initial commit --- src/T2DLL/LPeriodical.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/T2DLL/LPeriodical.cpp (limited to 'src/T2DLL/LPeriodical.cpp') diff --git a/src/T2DLL/LPeriodical.cpp b/src/T2DLL/LPeriodical.cpp new file mode 100644 index 0000000..1d75869 --- /dev/null +++ b/src/T2DLL/LPeriodical.cpp @@ -0,0 +1,71 @@ +#include "LArray.h" +#include "LPeriodical.h" + +/*static*/ LArray* LPeriodical::sIdlerQ = NULL; +/*static*/ LArray* LPeriodical::sRepeaterQ = NULL; + +LPeriodical::LPeriodical() { +} + +/*virtual*/ LPeriodical::~LPeriodical() { + StopIdling(); + StopRepeating(); +} + +/*virtual*/ void LPeriodical::StartIdling() { + if (!sIdlerQ) + sIdlerQ = new LArray; + + // how the hell is this supposed to work?? + // surely it should pass &this... + if (sIdlerQ->FetchIndexOf(this) == 0) + sIdlerQ->Add(this); +} + +/*virtual*/ void LPeriodical::StopIdling() { + if (sIdlerQ) + sIdlerQ->Remove(this); +} + +/*static*/ void LPeriodical::DevoteTimeToIdlers() { + if (sIdlerQ) { + LArrayIterator iter(*sIdlerQ); + LPeriodical *p; + + while (iter.Next(&p)) + p->SpendTime(); + } +} + +/*virtual*/ void LPeriodical::StartRepeating() { + if (!sRepeaterQ) + sRepeaterQ = new LArray; + + // how the hell is this supposed to work?? + // surely it should pass &this... + if (sRepeaterQ->FetchIndexOf(this) == 0) + sRepeaterQ->Add(this); +} + +/*virtual*/ void LPeriodical::StopRepeating() { + if (sRepeaterQ) + sRepeaterQ->Remove(this); +} + +/*static*/ void LPeriodical::DevoteTimeToRepeaters() { + if (sRepeaterQ) { + LArrayIterator iter(*sRepeaterQ); + LPeriodical *p; + + while (iter.Next(&p)) + p->SpendTime(); + } +} + +/*static*/ void LPeriodical::DeleteIdlerAndRepeaterQueues() { + delete sIdlerQ; + sIdlerQ = NULL; + + delete sRepeaterQ; + sRepeaterQ = NULL; +} -- cgit v1.2.3