summaryrefslogtreecommitdiffstats
path: root/src/Core/ThreadManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/ThreadManager.h')
-rw-r--r--src/Core/ThreadManager.h29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/Core/ThreadManager.h b/src/Core/ThreadManager.h
index b512ad4..c20cb1f 100644
--- a/src/Core/ThreadManager.h
+++ b/src/Core/ThreadManager.h
@@ -22,8 +22,6 @@
#include <config.h>
-#include "Initializable.h"
-
#include <queue>
#include <map>
@@ -36,8 +34,14 @@
namespace Mad {
namespace Core {
-class ThreadManager : public Initializable {
+class Application;
+
+class ThreadManager : private boost::noncopyable {
private:
+ friend class Application;
+
+ Application *application;
+
boost::thread::id mainThreadId;
boost::shared_ptr<boost::thread> workerThread, loggerThread, ioThread;
std::map<boost::thread::id, boost::shared_ptr<boost::thread> > threads;
@@ -53,11 +57,8 @@ class ThreadManager : public Initializable {
boost::scoped_ptr<boost::asio::io_service::work> ioWorker;
- boost::asio::io_service ioService;
-
- static ThreadManager threadManager;
-
- ThreadManager() {}
+ ThreadManager(Application *application0);
+ ~ThreadManager();
void workerFunc();
void ioFunc();
@@ -80,10 +81,6 @@ class ThreadManager : public Initializable {
thread->join();
}
- protected:
- virtual void doInit();
- virtual void doDeinit();
-
public:
bool isThisMainThread() {
return (mainThreadId == boost::this_thread::get_id());
@@ -94,17 +91,9 @@ class ThreadManager : public Initializable {
return (workerThread->get_id() == boost::this_thread::get_id());
}
- boost::asio::io_service& getIOService() {
- return ioService;
- }
-
void detach();
void pushWork(const boost::function0<void> &newWork);
-
- static ThreadManager* get() {
- return &threadManager;
- }
};
}