summaryrefslogtreecommitdiff
path: root/src/T2DLL/LPeriodical.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-06-14 00:50:34 +0100
committerAsh Wolf <ninji@wuffs.org>2023-06-14 00:50:34 +0100
commit37e364b2c6cc7487a1c888d256a73e5337bb7189 (patch)
treeeaf6e857382eef16c2dd940eb4125536fbe068bd /src/T2DLL/LPeriodical.cpp
downloadt2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.tar.gz
t2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.zip
initial commit
Diffstat (limited to '')
-rw-r--r--src/T2DLL/LPeriodical.cpp71
1 files changed, 71 insertions, 0 deletions
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;
+}