summaryrefslogtreecommitdiff
path: root/src/timers.cpp
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-10-02 22:19:19 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-10-02 22:19:19 +0000
commitdc4b9afebbea5c8ca2d5b86c84411153b1622f71 (patch)
tree92ca6661ccceea15a215e77f3879b4c036ada67c /src/timers.cpp
parent85b409df8577e2433724a056564ab62ff72c4c89 (diff)
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
Diffstat (limited to 'src/timers.cpp')
-rw-r--r--src/timers.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/timers.cpp b/src/timers.cpp
index 02e5a3f08..d7c56072b 100644
--- a/src/timers.cpp
+++ b/src/timers.cpp
@@ -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);
}
}