mirror of
https://github.com/anope/anope.git
synced 2026-06-25 23:26:38 +02:00
d44f7971b1
This allows modules (xmlrpc) to create and accept SSL connections. Also fixed unloading m_mysql at certain times and made the threading engine always work correctly on Windows.
60 lines
961 B
C++
60 lines
961 B
C++
#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()
|
|
{
|
|
Exit = true;
|
|
}
|
|
|
|
/** Returns the exit state of the thread
|
|
* @return true if we want to exit
|
|
*/
|
|
bool Thread::GetExitState() const
|
|
{
|
|
return Exit;
|
|
}
|
|
|
|
/** Called to run the thread, should be overloaded
|
|
*/
|
|
void Thread::Run()
|
|
{
|
|
}
|