From 63cb8ca24c0d4003343340bb8413b7f84de1a6a3 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 5 Sep 2011 18:44:43 -0400 Subject: Moved signal/thread/mode checking to use signal pipes --- include/modes.h | 10 ++++++++++ include/services.h | 31 +++++++++++++++---------------- include/threadengine.h | 41 +++++++++++------------------------------ 3 files changed, 36 insertions(+), 46 deletions(-) (limited to 'include') diff --git a/include/modes.h b/include/modes.h index 2fce7e9f7..1e85e3b64 100644 --- a/include/modes.h +++ b/include/modes.h @@ -375,6 +375,16 @@ class StackerInfo class CoreExport ModeManager { protected: + class ModePipe : public Pipe + { + public: + /** Called when there are modes to be set + */ + void OnNotify(); + }; + + static ModePipe *mpipe; + /* List of pairs of user/channels and their stacker info */ static std::list > StackerObjects; diff --git a/include/services.h b/include/services.h index 9ed5e2ba3..520182e98 100644 --- a/include/services.h +++ b/include/services.h @@ -241,22 +241,6 @@ class DatabaseException : public CoreException virtual ~DatabaseException() throw() { } }; -class Signal -{ - static std::vector SignalHandlers; - static void SignalHandler(int signal); - - struct sigaction action, old; - sig_atomic_t called; - public: - static void Process(); - - int signal; - - Signal(int s); - ~Signal(); - virtual void OnSignal() = 0; -}; /** Debug cast to be used instead of dynamic_cast, this uses dynamic_cast * for debug builds and static_cast on releass builds to speed up the program @@ -406,6 +390,21 @@ template class Service; /*************************************************************************/ +class Signal : public Pipe +{ + static std::vector SignalHandlers; + static void SignalHandler(int signal); + + struct sigaction action, old; + public: + int signal; + + Signal(int s); + ~Signal(); + + virtual void OnNotify() = 0; +}; + class ConvertException : public CoreException { public: diff --git a/include/threadengine.h b/include/threadengine.h index 20e3c81eb..06c4900a4 100644 --- a/include/threadengine.h +++ b/include/threadengine.h @@ -12,36 +12,9 @@ typedef pthread_mutex_t MutexHandle; typedef pthread_cond_t CondHandle; #endif -class ThreadEngine; class Thread; -extern CoreExport ThreadEngine threadEngine; - -class CoreExport ThreadEngine -{ - public: - /* Vector of threads */ - std::vector threads; - - /** Threadengines constructor - */ - ThreadEngine(); - - /** Threadengines destructor - */ - ~ThreadEngine(); - - /** Start a new thread - * @param thread A pointer to a newley allocated thread - */ - void Start(Thread *thread); - - /** Check for finished threads - */ - void Process(); -}; - -class CoreExport Thread : public Extensible +class CoreExport Thread : public Pipe, public Extensible { private: /* Set to true to tell the thread to finish and we are waiting for it */ @@ -71,14 +44,22 @@ class CoreExport Thread : public Extensible */ void Exit(); + /** Launch the thread + */ + void Start(); + /** Returns the exit state of the thread * @return true if we want to exit */ bool GetExitState() const; - /** Called to run the thread, should be overloaded + /** Called when this thread should be joined to + */ + void OnNotify(); + + /** Called when the thread is run. */ - virtual void Run(); + virtual void Run() = 0; }; class CoreExport Mutex -- cgit