aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorGravatar Sadie Powell2019-05-15 16:22:24 +0100
committerGravatar Sadie Powell2019-05-15 21:06:09 +0100
commit03d3563ef95efc6ab8076d66ebda48545c6089c4 (patch)
tree0160e0a3b333a000c7c880d9373b46cfa3968e79 /src/modules
parentMerge branch 'insp3' into master. (diff)
downloadinspircd++-03d3563ef95efc6ab8076d66ebda48545c6089c4.tar.gz
inspircd++-03d3563ef95efc6ab8076d66ebda48545c6089c4.tar.bz2
inspircd++-03d3563ef95efc6ab8076d66ebda48545c6089c4.zip
Replace socketengine_{pthread,win32} with C++11 threads.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_ldap.cpp22
-rw-r--r--src/modules/extra/m_mysql.cpp24
2 files changed, 23 insertions, 23 deletions
diff --git a/src/modules/extra/m_ldap.cpp b/src/modules/extra/m_ldap.cpp
index d6cad357b..fd5761cf6 100644
--- a/src/modules/extra/m_ldap.cpp
+++ b/src/modules/extra/m_ldap.cpp
@@ -251,7 +251,7 @@ class LDAPService : public LDAPProvider, public SocketThread
public:
typedef std::vector<LDAPRequest*> query_queue;
query_queue queries, results;
- Mutex process_mutex; /* held when processing requests not in either queue */
+ std::mutex process_mutex; /* held when processing requests not in either queue */
LDAPService(Module* c, ConfigTag* tag)
: LDAPProvider(c, "LDAP/" + tag->getString("id"))
@@ -431,7 +431,7 @@ class LDAPService : public LDAPProvider, public SocketThread
void SendRequests()
{
- process_mutex.Lock();
+ process_mutex.lock();
query_queue q;
this->LockQueue();
@@ -440,7 +440,7 @@ class LDAPService : public LDAPProvider, public SocketThread
if (q.empty())
{
- process_mutex.Unlock();
+ process_mutex.unlock();
return;
}
@@ -472,13 +472,13 @@ class LDAPService : public LDAPProvider, public SocketThread
this->NotifyParent();
- process_mutex.Unlock();
+ process_mutex.unlock();
}
public:
- void Run() override
+ void OnStart() override
{
- while (!this->GetExitFlag())
+ while (!this->IsStopping())
{
this->LockQueue();
if (this->queries.empty())
@@ -545,7 +545,7 @@ class ModuleLDAP : public Module
conns[id] = conn;
ServerInstance->Modules.AddService(*conn);
- ServerInstance->Threads.Start(conn);
+ conn->Start();
}
else
{
@@ -558,7 +558,7 @@ class ModuleLDAP : public Module
{
LDAPService* conn = i->second;
ServerInstance->Modules.DelService(*conn);
- conn->join();
+ conn->Stop();
conn->OnNotify();
delete conn;
}
@@ -572,7 +572,7 @@ class ModuleLDAP : public Module
{
LDAPService* s = it->second;
- s->process_mutex.Lock();
+ s->process_mutex.lock();
s->LockQueue();
for (unsigned int i = s->queries.size(); i > 0; --i)
@@ -600,7 +600,7 @@ class ModuleLDAP : public Module
}
s->UnlockQueue();
- s->process_mutex.Unlock();
+ s->process_mutex.unlock();
}
}
@@ -609,7 +609,7 @@ class ModuleLDAP : public Module
for (ServiceMap::iterator i = LDAPServices.begin(); i != LDAPServices.end(); ++i)
{
LDAPService* conn = i->second;
- conn->join();
+ conn->Stop();
conn->OnNotify();
delete conn;
}
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index bffc63b1a..20f9f23cd 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -119,7 +119,7 @@ class DispatcherThread : public SocketThread
public:
DispatcherThread(ModuleSQL* CreatorModule) : Parent(CreatorModule) { }
~DispatcherThread() { }
- void Run() override;
+ void OnStart() override;
void OnNotify() override;
};
@@ -241,7 +241,7 @@ class SQLConnection : public SQL::Provider
public:
reference<ConfigTag> config;
MYSQL *connection;
- Mutex lock;
+ std::mutex lock;
// This constructor creates an SQLConnection object with the given credentials, but does not connect yet.
SQLConnection(Module* p, ConfigTag* tag) : SQL::Provider(p, "SQL/" + tag->getString("id")),
@@ -397,14 +397,14 @@ ModuleSQL::ModuleSQL()
void ModuleSQL::init()
{
Dispatcher = new DispatcherThread(this);
- ServerInstance->Threads.Start(Dispatcher);
+ Dispatcher->Start();
}
ModuleSQL::~ModuleSQL()
{
if (Dispatcher)
{
- Dispatcher->join();
+ Dispatcher->Stop();
Dispatcher->OnNotify();
delete Dispatcher;
}
@@ -444,8 +444,8 @@ void ModuleSQL::ReadConfig(ConfigStatus& status)
{
ServerInstance->Modules.DelService(*i->second);
// it might be running a query on this database. Wait for that to complete
- i->second->lock.Lock();
- i->second->lock.Unlock();
+ i->second->lock.lock();
+ i->second->lock.unlock();
// now remove all active queries to this DB
for (size_t j = qq.size(); j > 0; j--)
{
@@ -478,8 +478,8 @@ void ModuleSQL::OnUnloadModule(Module* mod)
{
// need to wait until the query is done
// (the result will be discarded)
- qq[i].c->lock.Lock();
- qq[i].c->lock.Unlock();
+ qq[i].c->lock.lock();
+ qq[i].c->lock.unlock();
}
qq[i].q->OnError(err);
delete qq[i].q;
@@ -496,18 +496,18 @@ Version ModuleSQL::GetVersion()
return Version("Provides MySQL support", VF_VENDOR);
}
-void DispatcherThread::Run()
+void DispatcherThread::OnStart()
{
this->LockQueue();
- while (!this->GetExitFlag())
+ while (!this->IsStopping())
{
if (!Parent->qq.empty())
{
QQueueItem i = Parent->qq.front();
- i.c->lock.Lock();
+ i.c->lock.lock();
this->UnlockQueue();
MySQLresult* res = i.c->DoBlockingQuery(i.query);
- i.c->lock.Unlock();
+ i.c->lock.unlock();
/*
* At this point, the main thread could be working on: