summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-10 00:02:31 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-10 00:02:31 +0000
commitad3c37e38c6c170c1f7cc3232db748ebdc62aa94 (patch)
tree4b59a16e8bbd2241a4b49c953c089a9180e4a43c /src
parentf5872557eb0eee0f71f16ad39d693024f4cf8b1f (diff)
Relocate timer stuff into TimerManager class
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4827 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/inspircd.cpp5
-rw-r--r--src/modules.cpp5
-rw-r--r--src/modules/m_safelist.cpp6
-rw-r--r--src/timer.cpp12
4 files changed, 11 insertions, 17 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 6b4800887..a4b6181ab 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -293,6 +293,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
OpenLog(argv, argc);
this->stats = new serverstats();
this->Parser = new CommandParser();
+ this->Timers = new TimerManager();
Config->ClearStack();
Config->Read(true, NULL);
CheckRoot();
@@ -701,7 +702,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
{
FOREACH_MOD(I_OnBackgroundTimer,OnBackgroundTimer(TIME));
}
- TickMissedTimers(TIME);
+ Timers->TickMissedTimers(TIME);
expire_run = true;
return;
}
@@ -735,7 +736,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
if (process_module_sockets)
this->DoSocketTimeouts(TIME);
- TickTimers(TIME);
+ Timers->TickTimers(TIME);
/* Call the socket engine to wait on the active
* file descriptors. The socket engine has everything's
diff --git a/src/modules.cpp b/src/modules.cpp
index 22083fa66..1566ac5d7 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -375,11 +375,6 @@ chanrec* Server::GetChannelIndex(long index)
return NULL;
}
-void Server::AddTimer(InspTimer* T)
-{
- ::AddTimer(T);
-}
-
void Server::SendOpers(const std::string &s)
{
WriteOpers("%s",s.c_str());
diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp
index 45177805e..000d1e7d6 100644
--- a/src/modules/m_safelist.cpp
+++ b/src/modules/m_safelist.cpp
@@ -26,6 +26,8 @@ using namespace std;
extern time_t TIME;
+extern InspIRCd* ServerInstance;
+
class ListData : public classbase
{
public:
@@ -131,7 +133,7 @@ class ListTimer : public InspTimer
}
ListTimer* MyTimer = new ListTimer(1,Srv);
- Srv->AddTimer(MyTimer);
+ ServerInstance->Timers->AddTimer(MyTimer);
}
};
@@ -146,7 +148,7 @@ class ModuleSafeList : public Module
Srv = Me;
MyTimer = new ListTimer(1,Srv);
- Srv->AddTimer(MyTimer);
+ ServerInstance->Timers->AddTimer(MyTimer);
}
virtual ~ModuleSafeList()
diff --git a/src/timer.cpp b/src/timer.cpp
index f35a9c67b..2b30b478c 100644
--- a/src/timer.cpp
+++ b/src/timer.cpp
@@ -22,12 +22,7 @@
#include "helperfuncs.h"
#include "timer.h"
-typedef std::vector<InspTimer*> timergroup;
-typedef std::map<time_t, timergroup*> timerlist;
-
-timerlist Timers;
-
-void TickTimers(time_t TIME)
+void TimerManager::TickTimers(time_t TIME)
{
timerlist::iterator found = Timers.find(TIME);
@@ -57,7 +52,7 @@ void TickTimers(time_t TIME)
* If you move your clock BACK, and your timers move further ahead as a result,
* then tough titty you'll just have to wait.
*/
-void TickMissedTimers(time_t TIME)
+void TimerManager::TickMissedTimers(time_t TIME)
{
for (time_t n = TIME-1; n > TIME-120; n--)
{
@@ -78,7 +73,7 @@ void TickMissedTimers(time_t TIME)
}
}
-void AddTimer(InspTimer* T)
+void TimerManager::AddTimer(InspTimer* T)
{
timergroup* x = NULL;
@@ -96,3 +91,4 @@ void AddTimer(InspTimer* T)
x->push_back(T);
}
+