summaryrefslogtreecommitdiff
path: root/src/T2DLL/LPeriodical.cpp
diff options
context:
space:
mode:
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;
+}