mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-14 03:38:33 +00:00
Remove Mutex class, replace with std::mutex
Also removes unused Condition class
This commit is contained in:
@@ -20,9 +20,12 @@
|
||||
#include "common/eqemu_config.h"
|
||||
#include "common/repositories/zone_repository.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <csignal>
|
||||
#include <thread>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
Database db;
|
||||
Database db2;
|
||||
|
||||
@@ -60,8 +63,6 @@ void WorldserverCLI::TestDatabaseConcurrency(int argc, char **argv, argh::parser
|
||||
|
||||
LogInfo("Database test");
|
||||
|
||||
auto mutex = new Mutex;
|
||||
|
||||
auto c = EQEmuConfig::get();
|
||||
LogInfo("Connecting to MySQL");
|
||||
if (!db.Connect(
|
||||
@@ -75,19 +76,19 @@ void WorldserverCLI::TestDatabaseConcurrency(int argc, char **argv, argh::parser
|
||||
return;
|
||||
}
|
||||
|
||||
db.SetMutex(mutex);
|
||||
std::shared_ptr<std::mutex> sharedMutex = std::make_shared<std::mutex>();
|
||||
|
||||
db.SetMutex(sharedMutex);
|
||||
|
||||
db2.SetMySQL(db);
|
||||
|
||||
db2.SetMutex(mutex);
|
||||
db2.SetMutex(sharedMutex);
|
||||
|
||||
std::thread(DatabaseTest).detach();
|
||||
std::thread(DatabaseTest).detach();
|
||||
std::thread(DatabaseTestSecondConnection).detach();
|
||||
|
||||
while (!stop) {
|
||||
|
||||
std::this_thread::sleep_for(0s);
|
||||
}
|
||||
|
||||
safe_delete(mutex);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "common/eq_packet_structs.h"
|
||||
#include "common/event/timer.h"
|
||||
#include "common/linked_list.h"
|
||||
#include "common/mutex.h"
|
||||
#include "common/net/servertalk_client_connection.h"
|
||||
#include "common/net/servertalk_legacy_client_connection.h"
|
||||
#include "common/queue.h"
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/eq_packet_structs.h"
|
||||
#include "common/mutex.h"
|
||||
#include "common/queue.h"
|
||||
#include "common/servertalk.h"
|
||||
#include "common/timer.h"
|
||||
|
||||
@@ -49,8 +49,6 @@
|
||||
|
||||
extern WorldConfig Config;
|
||||
|
||||
auto mutex = new Mutex;
|
||||
|
||||
void WorldBoot::GMSayHookCallBackProcessWorld(uint16 log_category, const char *func, std::string message)
|
||||
{
|
||||
// we don't want to loop up with chat messages
|
||||
@@ -180,11 +178,13 @@ bool WorldBoot::LoadDatabaseConnections()
|
||||
}
|
||||
else {
|
||||
content_db.SetMySQL(database);
|
||||
|
||||
// when database and content_db share the same underlying mysql connection
|
||||
// it needs to be protected by a shared mutex otherwise we produce concurrency issues
|
||||
// when database actions are occurring in different threads
|
||||
database.SetMutex(mutex);
|
||||
content_db.SetMutex(mutex);
|
||||
std::shared_ptr<std::mutex> sharedMutex = std::make_shared<std::mutex>();
|
||||
database.SetMutex(sharedMutex);
|
||||
content_db.SetMutex(sharedMutex);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -634,7 +634,6 @@ void WorldBoot::CheckForPossibleConfigurationIssues()
|
||||
|
||||
void WorldBoot::Shutdown()
|
||||
{
|
||||
safe_delete(mutex);
|
||||
}
|
||||
|
||||
void WorldBoot::SendDiscordMessage(int webhook_id, const std::string &message)
|
||||
|
||||
Reference in New Issue
Block a user