diff options
author | Adam <Adam@anope.org> | 2013-03-30 23:38:40 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-03-30 23:39:43 -0500 |
commit | 7e7556f06445d4d8e607ef514c9fb5009899db73 (patch) | |
tree | fde8e4e7c59f40183e215cd69ce0d042670b24b9 /src/timers.cpp | |
parent | 111d6a917806fd3ce2269436d08d68bd7eb1d5ea (diff) |
Merge usefulness of Timer and CallBack classes into Timer, and fix it to really work
Diffstat (limited to 'src/timers.cpp')
-rw-r--r-- | src/timers.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/timers.cpp b/src/timers.cpp index 94a6fbb3d..827d81df7 100644 --- a/src/timers.cpp +++ b/src/timers.cpp @@ -14,6 +14,18 @@ std::multimap<time_t, Timer *> TimerManager::Timers; Timer::Timer(long time_from_now, time_t now, bool repeating) { + owner = NULL; + trigger = now + time_from_now; + secs = time_from_now; + repeat = repeating; + settime = now; + + TimerManager::AddTimer(this); +} + +Timer::Timer(Module *creator, long time_from_now, time_t now, bool repeating) +{ + owner = creator; trigger = now + time_from_now; secs = time_from_now; repeat = repeating; @@ -62,6 +74,11 @@ long Timer::GetSecs() const return secs; } +Module *Timer::GetOwner() const +{ + return owner; +} + void TimerManager::AddTimer(Timer *t) { Timers.insert(std::make_pair(t->GetTimer(), t)); @@ -98,3 +115,14 @@ void TimerManager::TickTimers(time_t ctime) delete t; } } + +void TimerManager::DeleteTimersFor(Module *m) +{ + for (std::multimap<time_t, Timer *>::iterator it = Timers.begin(), it_next = it; it != Timers.end(); it = it_next) + { + ++it_next; + if (it->second->GetOwner() == m) + delete it->second; + } +} + |