mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-06 07:46:06 +00:00
Properly add RWMutex
This commit is contained in:
@@ -27,8 +27,9 @@ void HandleInput(const std::string& cmd) {
|
||||
std::cout << std::endl;
|
||||
if (cmd == "exit") {
|
||||
_Exit(0);
|
||||
} else
|
||||
} else {
|
||||
LuaConsole->Execute(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessOut() {
|
||||
|
||||
@@ -7,14 +7,10 @@
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
|
||||
using RWMutex = std::shared_mutex;
|
||||
using ReadLock = std::shared_lock<RWMutex>;
|
||||
using WriteLock = std::unique_lock<RWMutex>;
|
||||
#include "RWMutex.h"
|
||||
|
||||
static RWMutex ThreadNameMapMutex;
|
||||
static std::unordered_map<std::thread::id, std::string> ThreadNameMap;
|
||||
@@ -29,7 +25,6 @@ std::string ThreadName() {
|
||||
ss << std::this_thread::get_id();
|
||||
Name = ss.str();
|
||||
}
|
||||
lock.unlock();
|
||||
return Name;
|
||||
}
|
||||
|
||||
@@ -38,7 +33,6 @@ void SetThreadName(const std::string& Name, bool overwrite) {
|
||||
if (overwrite || ThreadNameMap.find(std::this_thread::get_id()) == ThreadNameMap.end()) {
|
||||
ThreadNameMap[std::this_thread::get_id()] = Name;
|
||||
}
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
std::string getDate() {
|
||||
|
||||
Reference in New Issue
Block a user