mirror of
https://github.com/SantaSpeen/BeamMP-Server.git
synced 2025-08-18 12:45:36 +00:00
Replace some mutex locks with scoped locks
This commit is contained in:
parent
94f6a81673
commit
8f05cdcc61
@ -92,11 +92,10 @@ void DebugPrintTIDInternal(const std::string& func, bool overwrite) {
|
|||||||
// due to segfaults or asserts.
|
// due to segfaults or asserts.
|
||||||
SetThreadName(func, overwrite);
|
SetThreadName(func, overwrite);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
LogLock.lock();
|
std::scoped_lock Guard(LogLock);
|
||||||
std::stringstream Print;
|
std::stringstream Print;
|
||||||
Print << "(debug build) Thread '" << std::this_thread::get_id() << "' is " << func << "\n";
|
Print << "(debug build) Thread '" << std::this_thread::get_id() << "' is " << func << "\n";
|
||||||
ConsoleOut(Print.str());
|
ConsoleOut(Print.str());
|
||||||
LogLock.unlock();
|
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,39 +106,34 @@ void addToLog(const std::string& Line) {
|
|||||||
LFS.close();
|
LFS.close();
|
||||||
}
|
}
|
||||||
void info(const std::string& toPrint) {
|
void info(const std::string& toPrint) {
|
||||||
LogLock.lock();
|
std::scoped_lock Guard(LogLock);
|
||||||
std::string Print = getDate() + Sec("[INFO] ") + toPrint + "\n";
|
std::string Print = getDate() + Sec("[INFO] ") + toPrint + "\n";
|
||||||
ConsoleOut(Print);
|
ConsoleOut(Print);
|
||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
LogLock.unlock();
|
|
||||||
}
|
}
|
||||||
void debug(const std::string& toPrint) {
|
void debug(const std::string& toPrint) {
|
||||||
if (!Debug)
|
if (!Debug)
|
||||||
return;
|
return;
|
||||||
LogLock.lock();
|
std::scoped_lock Guard(LogLock);
|
||||||
std::string Print = getDate() + Sec("[DEBUG] ") + toPrint + "\n";
|
std::string Print = getDate() + Sec("[DEBUG] ") + toPrint + "\n";
|
||||||
ConsoleOut(Print);
|
ConsoleOut(Print);
|
||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
LogLock.unlock();
|
|
||||||
}
|
}
|
||||||
void warn(const std::string& toPrint) {
|
void warn(const std::string& toPrint) {
|
||||||
LogLock.lock();
|
std::scoped_lock Guard(LogLock);
|
||||||
std::string Print = getDate() + Sec("[WARN] ") + toPrint + "\n";
|
std::string Print = getDate() + Sec("[WARN] ") + toPrint + "\n";
|
||||||
ConsoleOut(Print);
|
ConsoleOut(Print);
|
||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
LogLock.unlock();
|
|
||||||
}
|
}
|
||||||
void error(const std::string& toPrint) {
|
void error(const std::string& toPrint) {
|
||||||
LogLock.lock();
|
std::scoped_lock Guard(LogLock);
|
||||||
std::string Print = getDate() + Sec("[ERROR] ") + toPrint + "\n";
|
std::string Print = getDate() + Sec("[ERROR] ") + toPrint + "\n";
|
||||||
ConsoleOut(Print);
|
ConsoleOut(Print);
|
||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
LogLock.unlock();
|
|
||||||
}
|
}
|
||||||
void except(const std::string& toPrint) {
|
void except(const std::string& toPrint) {
|
||||||
LogLock.lock();
|
std::scoped_lock Guard(LogLock);
|
||||||
std::string Print = getDate() + Sec("[EXCEP] ") + toPrint + "\n";
|
std::string Print = getDate() + Sec("[EXCEP] ") + toPrint + "\n";
|
||||||
ConsoleOut(Print);
|
ConsoleOut(Print);
|
||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
LogLock.unlock();
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user