]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Relocate timer stuff into TimerManager class
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 10 Aug 2006 00:02:31 +0000 (00:02 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 10 Aug 2006 00:02:31 +0000 (00:02 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4827 e03df62e-2008-0410-955e-edbf42e46eb7

include/dynamic.h
include/inspircd.h
include/modules.h
include/timer.h
src/inspircd.cpp
src/modules.cpp
src/modules/m_safelist.cpp
src/timer.cpp

index a8b7392bf73e547e65b3fe1afa0b12d16d24662c..386ebb376fdcf03dd5ed668dab7a234be31664e0 100644 (file)
@@ -22,8 +22,6 @@ typedef void * (initfunc) (void);
 
 #include "inspircd_config.h"
 
-extern void do_log(int, const char*, ...);
-
 class DLLManager
 {
  public:
index f901200cdd6840cac871889639f832c6bb5c0feb..7cd1d973d1ca4b3f5ffe60a3bb46844e545a64bd 100644 (file)
@@ -116,6 +116,7 @@ class InspIRCd : public classbase
        chan_hash chanlist;
        std::vector<userrec*> local_users;
        DNS* Res;
+       TimerManager* Timers;
 
        void AddServerName(const std::string &servername);
        const char* FindServerNamePtr(const std::string &servername);
index b0d249c7c73d8d52060a11cec5f500c338acba0c..aca4f06ea21eedfa6ef96a5c6806c56615c119b7 100644 (file)
@@ -1357,10 +1357,6 @@ class Server : public Extensible
         */
        virtual bool IsNick(const std::string &nick);
 
-       /** Adds an InspTimer which will trigger at a future time
-        */
-       virtual void AddTimer(InspTimer* T);
-
        /** Attempts to look up a nick and return a pointer to it.
         * This function will return NULL if the nick does not exist.
         */
index ec00abe4ffa6fff0bc8081742f8a6e4979d21417..4d1eee470f5fc944a5932d50668b008eff583768 100644 (file)
@@ -54,8 +54,21 @@ class InspTimer : public Extensible
        virtual void Tick(time_t TIME) = 0;
 };
 
-void TickTimers(time_t TIME);
-void AddTimer(InspTimer* T);
-void TickMissedTimers(time_t TIME);
+class TimerManager : public Extensible
+{
+ protected:
+
+       typedef std::vector<InspTimer*> timergroup;
+       typedef std::map<time_t, timergroup*> timerlist;
+
+ private:
+
+       timerlist Timers;
+
+ public:
+       void TickTimers(time_t TIME);
+       void AddTimer(InspTimer* T);
+       void TickMissedTimers(time_t TIME);
+};
 
 #endif
index 6b480088744f70fe61fc1118f2709c84249c175f..a4b6181abd20ba0830aa3c97f7f1b0c4178dbf6d 100644 (file)
@@ -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
index 22083fa669fa51193f183fbbb9289017ae5fe4f3..1566ac5d752f7f2d5a04f0d5debf15160a190e56 100644 (file)
@@ -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());
index 45177805ec9790975938d7fc3817086e01caa380..000d1e7d64dd5aa89492304d1e06ff4c540d9c1f 100644 (file)
@@ -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()
index f35a9c67be4acc39b5d8a992bc131eaba667495c..2b30b478cf592eed5806b27d8d137449fb125cf9 100644 (file)
 #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);
 }
+