#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; }