00001 // -*- c++ -*- 00002 //------------------------------------------------------------------------------ 00003 // TimerQueue.cpp 00004 //------------------------------------------------------------------------------ 00005 // Copyright (c) 2000,2005 by Vladislav Grinchenko 00006 // 00007 // This library is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU Library General Public 00009 // License as published by the Free Software Foundation; either 00010 // version 2 of the License, or (at your option) any later version. 00011 // 00012 //------------------------------------------------------------------------------ 00013 // Created: 07/28/99 00014 //------------------------------------------------------------------------------ 00015 00016 #include "assa/TimerQueue.h" 00017 using namespace ASSA; 00018 00019 TimerQueue:: 00020 ~TimerQueue () 00021 { 00022 trace_with_mask("TimerQueue::~TimerQueue",REACTTRACE); 00023 00024 while (m_queue.size ()) { 00025 delete m_queue.pop (); 00026 } 00027 } 00028 00029 int 00030 TimerQueue:: 00031 remove (EventHandler* eh_) 00032 { 00033 // Like STL iterators, after deletion of an element, 00034 // queue structure and indexing might drastically change 00035 // and there is no guarantee that elements we haven't seen 00036 // yet will not be moved past the iterator. Therefore, 00037 // we must start scanning from the beginning after each deletion :-( 00038 00039 trace_with_mask("TimerQueue::remove(eh_)",REACTTRACE); 00040 00041 register size_t i; 00042 int cnt = 0; 00043 bool f = true; // changed flag 00044 register Timer* tmr; 00045 00046 DL((REACT,"Searching for Timer: 0x%x\n", dynamic_cast<void*> (eh_))); 00047 00048 while (f) { 00049 f = false; 00050 DL((REACT,"Queue size: %d\n", m_queue.size())); 00051 for (i = 0; i < m_queue.size (); i++) { 00052 if (m_queue[i]->getHandler() == eh_) { 00053 DL((REACT,"Found Timer: 0x%x in slot: %d\n", 00054 dynamic_cast<void*>(eh_), i)); 00055 tmr = m_queue[i]; 00056 m_queue.remove (tmr); 00057 delete tmr; 00058 cnt++; 00059 f = true; 00060 } 00061 } 00062 } 00063 return cnt; 00064 } 00065 00066 bool 00067 TimerQueue:: 00068 remove (Timer.html">Main Page
#include "assa/TimerQueue.h"Go to the source code of this file.
1.6.1