summaryrefslogtreecommitdiffstats
path: root/src/Net/ThreadManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Net/ThreadManager.cpp')
-rw-r--r--src/Net/ThreadManager.cpp58
1 files changed, 5 insertions, 53 deletions
diff --git a/src/Net/ThreadManager.cpp b/src/Net/ThreadManager.cpp
index 9eb965d..3495196 100644
--- a/src/Net/ThreadManager.cpp
+++ b/src/Net/ThreadManager.cpp
@@ -96,40 +96,6 @@ void ThreadManager::pushWork(const sigc::slot<void> &newWork) {
gl_lock_unlock(workLock);
}
-void ThreadManager::pushIO(const sigc::slot<void> &newIO) {
- gl_lock_lock(ioLock);
-
- ioQueue.push(newIO);
-
- if(!hasIO) {
- hasIO = true;
- ignore_value(write(ioNotifyPipe[1], "", 1));
- }
-
- gl_lock_unlock(ioLock);
-}
-
-void ThreadManager::runIO() {
- gl_lock_lock(ioLock);
-
- // Empty the pipe
- char buf;
- ignore_value(read(ioNotifyPipe[0], &buf, 1));
- hasIO = false;
-
- while(!ioQueue.empty()) {
- sigc::slot<void> handler = ioQueue.front();
- ioQueue.pop();
- gl_lock_unlock(ioLock);
-
- handler();
-
- gl_lock_lock(ioLock);
- }
-
- gl_lock_unlock(ioLock);
-}
-
void ThreadManager::doInit() {
gl_lock_init(threadLock);
@@ -138,17 +104,6 @@ void ThreadManager::doInit() {
gl_lock_init(workLock);
gl_cond_init(workCond);
- gl_lock_init(ioLock);
- hasIO = false;
-
- // TODO Error handling
- pipe(ioNotifyPipe);
-
- fcntl(ioNotifyPipe[0], F_SETFL, fcntl(ioNotifyPipe[0], F_GETFL) | O_NONBLOCK);
- fcntl(ioNotifyPipe[1], F_SETFL, fcntl(ioNotifyPipe[1], F_GETFL) | O_NONBLOCK);
-
- Net::FdManager::get()->registerFd(ioNotifyPipe[0], sigc::hide(sigc::mem_fun(this, &ThreadManager::runIO)), POLLIN);
-
running = true;
gl_lock_lock(threadLock);
@@ -156,6 +111,7 @@ void ThreadManager::doInit() {
mainThread = (gl_thread_t)gl_thread_self();
workerThread = gl_thread_create(&ThreadManager::workerStart, 0);
loggerThread = gl_thread_create(&ThreadManager::loggerStart, 0);
+ ioThread = gl_thread_create(&ThreadManager::ioStart, 0);
gl_lock_unlock(threadLock);
}
@@ -192,18 +148,14 @@ void ThreadManager::doDeinit() {
}
gl_lock_unlock(threadLock);
+ // IO thread is next
+ FdManager::get()->stopIOThread();
+ gl_thread_join(ioThread, 0);
+
// Finally, the logger thread has to die
Common::LogManager::get()->stopLoggerThread();
gl_thread_join(loggerThread, 0);
- // And then we clean everything up
- Net::FdManager::get()->unregisterFd(ioNotifyPipe[0]);
-
- close(ioNotifyPipe[0]);
- close(ioNotifyPipe[1]);
-
- gl_lock_destroy(ioLock);
-
gl_cond_destroy(workCond);
gl_lock_destroy(workLock);