diff options
author | Adam <Adam@anope.org> | 2011-09-05 18:44:43 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-09-10 02:06:31 -0400 |
commit | 63cb8ca24c0d4003343340bb8413b7f84de1a6a3 (patch) | |
tree | d71f0cead730065dd8509e284d66b6767e7ebd25 /src/threadengine.cpp | |
parent | dc5d1fa21c20000b77bf713585333c79121a8df0 (diff) |
Moved signal/thread/mode checking to use signal pipes
Diffstat (limited to 'src/threadengine.cpp')
-rw-r--r-- | src/threadengine.cpp | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/src/threadengine.cpp b/src/threadengine.cpp index c2aa3da20..e11b065ea 100644 --- a/src/threadengine.cpp +++ b/src/threadengine.cpp @@ -1,46 +1,22 @@ #include "services.h" -ThreadEngine threadEngine; - -/** Check for finished threads - */ -void ThreadEngine::Process() -{ - for (unsigned i = this->threads.size(); i > 0; --i) - { - Thread *t = this->threads[i - 1]; - - if (t->GetExitState()) - { - t->Join(); - delete t; - } - } -} - /** Threads constructor */ Thread::Thread() : exit(false) { - threadEngine.threads.push_back(this); } /** Threads destructor */ Thread::~Thread() { - std::vector<Thread *>::iterator it = std::find(threadEngine.threads.begin(), threadEngine.threads.end(), this); - - if (it != threadEngine.threads.end()) - { - threadEngine.threads.erase(it); - } } /** Sets the exit state as true informing the thread we want it to shut down */ void Thread::SetExitState() { + this->Notify(); exit = true; } @@ -52,8 +28,11 @@ bool Thread::GetExitState() const return exit; } -/** Called to run the thread, should be overloaded +/** Called when this thread should be joined to */ -void Thread::Run() +void Thread::OnNotify() { + this->Join(); + this->SetFlag(SF_DEAD); } + |