//---------------------------------------------------------------------- void WorldTime::fireWorldTimeCame() { while(true) { // Process the first listener - the listener // with earliest activation time. Listeners::Iterator it = mListeners.getIterator(); if(!it.hasMoreElements()) break; // no listeners to process Time activationTime = it.peekNextKey(); if(activationTime > mCurrentTime) break; // all required listeners have been processed WorldTimeListener* listener = it.peekNextValue(); Time period = listener->mPeriod; Time nextActivationTime; if(period != Time::INFINITY) nextActivationTime = activationTime + period; else nextActivationTime = Time::INFINITY; // next activation time = never // Call the listener. WorldTimeEvent evt(activationTime, nextActivationTime); listener->worldTimeCame(evt); nextActivationTime = evt.getNextActivationTime(); // The worldTriggered function could remove the listener, // so we check if the iterator points to the same listener yet. if(!it.hasMoreElements() || it.peekNextValue() != listener) continue; // process next listener // Remove the listener from the ordered list, // increase the activation time by period, // and insert the listener to the ordered list again. _removeListener(listener); if(nextActivationTime != Time::INFINITY) { _addListener(listener, nextActivationTime, period); } } }
static Boolean _addBlock( iOFBack inst, iIBlockBase listener ) { iOFBackData data = Data(inst); return _addListener(inst, (obj)listener); }
bool Object::addListener(uint32_t code, void (*fn)()) { Delegate0<> del(fn); return _addListener(code, NULL, (const void*)&del, OBJECT_EVENT_HANDLER_VOID); }
bool Object::addListener(uint32_t code, void (*fn)(Event*)) { Delegate1<Event*> del(fn); return _addListener(code, NULL, (const void*)&del, OBJECT_EVENT_HANDLER_EVENTPTR); }