mirror of
https://github.com/anope/anope.git
synced 2026-06-26 17:56:38 +02:00
Properly remove old callbacks from modules internal list of callbacks list, and cleaned up some of the timers code
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2524 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
+19
-6
@@ -99,8 +99,24 @@ void TimerManager::DelTimer(Timer *T)
|
||||
}
|
||||
}
|
||||
|
||||
/** Check if something is a timer
|
||||
* @param T A pointer
|
||||
* @return true or false
|
||||
*/
|
||||
bool TimerManager::IsTimer(Timer *T)
|
||||
{
|
||||
std::vector<Timer *>::iterator i = std::find(Timers.begin(), Timers.end(), T);
|
||||
|
||||
if (i != Timers.end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Tick all pending timers
|
||||
* @param time The current time
|
||||
* @param ctime The current time
|
||||
*/
|
||||
void TimerManager::TickTimers(time_t ctime)
|
||||
{
|
||||
@@ -110,20 +126,17 @@ void TimerManager::TickTimers(time_t ctime)
|
||||
while ((Timers.size()) && (ctime > (*Timers.begin())->GetTimer()))
|
||||
{
|
||||
i = Timers.begin();
|
||||
|
||||
t = *i;
|
||||
|
||||
t->Tick(ctime);
|
||||
|
||||
Timers.erase(i);
|
||||
|
||||
if (t->GetRepeat())
|
||||
{
|
||||
t->SetTimer(ctime + t->GetSecs());
|
||||
AddTimer(t);
|
||||
sort(Timers.begin(), Timers.end(), TimerManager::TimerComparison);
|
||||
}
|
||||
else
|
||||
delete t;
|
||||
TimerManager::DelTimer(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user