mirror of
https://github.com/anope/anope.git
synced 2026-06-25 16:46:37 +02:00
Moved signal/thread/mode checking to use signal pipes
This commit is contained in:
+6
-27
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user