mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-13 23:28:21 +00:00
Remove Mutex class, replace with std::mutex
Also removes unused Condition class
This commit is contained in:
+4
-6
@@ -26,7 +26,6 @@
|
||||
#include "common/guilds.h"
|
||||
#include "common/memory_mapped_file.h"
|
||||
#include "common/misc.h"
|
||||
#include "common/mutex.h"
|
||||
#include "common/net/eqstream.h"
|
||||
#include "common/opcodemgr.h"
|
||||
#include "common/patches/patches.h"
|
||||
@@ -216,8 +215,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
auto mutex = new Mutex;
|
||||
|
||||
LogInfo("Connecting to MySQL");
|
||||
if (!database.Connect(
|
||||
Config->DatabaseHost.c_str(),
|
||||
@@ -245,11 +242,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
|
||||
//rules:
|
||||
@@ -661,7 +660,6 @@ int main(int argc, char **argv)
|
||||
LogInfo("Proper zone shutdown complete.");
|
||||
EQEmuLogSys::Instance()->CloseFileLogs();
|
||||
|
||||
safe_delete(mutex);
|
||||
safe_delete(QServ);
|
||||
|
||||
return 0;
|
||||
|
||||
+9
-8
@@ -135,10 +135,11 @@ void PetitionList::AddPetition(Petition* pet) {
|
||||
}
|
||||
|
||||
//Return Values: 0 = Ok ; -1 = Error deleting petition.
|
||||
int PetitionList::DeletePetition(uint32 petnumber) {
|
||||
int PetitionList::DeletePetition(uint32 petnumber)
|
||||
{
|
||||
LinkedListIterator<Petition*> iterator(list);
|
||||
iterator.Reset();
|
||||
LockMutex lock(&PList_Mutex);
|
||||
std::scoped_lock lock(PList_Mutex);
|
||||
while(iterator.MoreElements()) {
|
||||
if (iterator.GetData()->GetID() == petnumber) {
|
||||
database.DeletePetitionFromDB(iterator.GetData());
|
||||
@@ -179,18 +180,18 @@ void PetitionList::ClearPetitions() {
|
||||
return;
|
||||
}
|
||||
|
||||
void PetitionList::ReadDatabase() {
|
||||
LockMutex lock(&PList_Mutex);
|
||||
void PetitionList::ReadDatabase()
|
||||
{
|
||||
std::scoped_lock lock(PList_Mutex);
|
||||
ClearPetitions();
|
||||
database.RefreshPetitionsFromDB();
|
||||
UpdateGMQueue();
|
||||
return;
|
||||
}
|
||||
|
||||
void PetitionList::UpdatePetition(Petition* pet) {
|
||||
LockMutex lock(&PList_Mutex);
|
||||
void PetitionList::UpdatePetition(Petition* pet)
|
||||
{
|
||||
std::scoped_lock lock(PList_Mutex);
|
||||
database.UpdatePetitionToDB(pet);
|
||||
return;
|
||||
}
|
||||
|
||||
void ZoneDatabase::DeletePetitionFromDB(Petition* wpet) {
|
||||
|
||||
+3
-6
@@ -18,12 +18,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/linked_list.h"
|
||||
#include "common/misc_functions.h"
|
||||
#include "common/mutex.h"
|
||||
#include "common/types.h"
|
||||
#include "common/zone_store.h"
|
||||
#include "zone/client.h"
|
||||
#include "zone/zonedb.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
class Client;
|
||||
|
||||
@@ -118,5 +115,5 @@ public:
|
||||
|
||||
private:
|
||||
LinkedList<Petition*> list;
|
||||
Mutex PList_Mutex;
|
||||
std::mutex PList_Mutex;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user