mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-03 07:20:22 +01:00
refactor: change typedef, nullptr, scoped_lock and others
This commit is contained in:
@@ -180,7 +180,7 @@ void WriteLog(std::string_view str, logtype type, bool isError)
|
||||
|
||||
const auto message = FormatLogMessage(str);
|
||||
|
||||
std::lock_guard<std::mutex> lock(logMutex);
|
||||
std::scoped_lock lock(logMutex);
|
||||
InfoStack.push_back({message, isError});
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ void ErrorLog(std::string_view str, logtype type)
|
||||
|
||||
const auto message = FormatLogMessage(str);
|
||||
|
||||
std::lock_guard<std::mutex> lock(logMutex);
|
||||
std::scoped_lock lock(logMutex);
|
||||
ErrorStack.push_back(message);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ crash_reporter::crash_reporter()
|
||||
|
||||
database = crashpad::CrashReportDatabase::Initialize(db);
|
||||
|
||||
if (database == nullptr || database->GetSettings() == NULL)
|
||||
if (database == nullptr || database->GetSettings() == nullptr)
|
||||
return;
|
||||
|
||||
std::vector<crashpad::CrashReportDatabase::Report> reports;
|
||||
|
||||
@@ -119,7 +119,7 @@ class cParser //: public std::stringstream
|
||||
std::size_t mLine { 0 }; // currently processed line
|
||||
bool mIncFile { false }; // the parser is processing an *.inc file
|
||||
bool mFirstToken { true }; // processing first token in the current file; helper used when checking for utf bom
|
||||
typedef std::map<std::string, std::string> commentmap;
|
||||
using commentmap = std::map<std::string, std::string>;
|
||||
commentmap mComments {
|
||||
commentmap::value_type( "/*", "*/" ),
|
||||
commentmap::value_type( "//", "\n" ) };
|
||||
|
||||
@@ -127,14 +127,14 @@ bool ClearFlag(int &Flag, int const Value)
|
||||
double Random(double min, double max)
|
||||
{
|
||||
if (max < min) { std::swap(min, max); } // std::uniform_real_distribution requires min <= max (inverted bounds are UB)
|
||||
std::uniform_real_distribution<double> dist(min, max);
|
||||
std::uniform_real_distribution dist(min, max);
|
||||
return dist(Global.random_engine);
|
||||
}
|
||||
|
||||
int Random(int min, int max)
|
||||
{
|
||||
if (max < min) { std::swap(min, max); } // std::uniform_int_distribution requires min <= max (inverted bounds are UB)
|
||||
std::uniform_int_distribution<int> dist(min, max);
|
||||
std::uniform_int_distribution dist(min, max);
|
||||
return dist(Global.random_engine);
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ std::uint32_t seed_of(std::string const &Text)
|
||||
|
||||
std::string generate_uuid_v4()
|
||||
{
|
||||
std::uniform_int_distribution<int> dist(0, 255);
|
||||
std::uniform_int_distribution dist(0, 255);
|
||||
|
||||
std::array<uint8_t, 16> bytes;
|
||||
for (auto &b : bytes)
|
||||
@@ -203,7 +203,7 @@ std::string generate_uuid_v4()
|
||||
double LocalRandom(double a, double b)
|
||||
{
|
||||
if (b < a) { std::swap(a, b); } // std::uniform_real_distribution requires a <= b (inverted bounds are UB)
|
||||
std::uniform_real_distribution<double> dist(a, b);
|
||||
std::uniform_real_distribution dist(a, b);
|
||||
return dist(Global.local_random_engine);
|
||||
}
|
||||
|
||||
|
||||
@@ -419,12 +419,12 @@ class condition_variable
|
||||
// methods
|
||||
void wait()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
std::unique_lock lock(m_mutex);
|
||||
m_condition.wait(lock, [this]() { return m_spurious == false; });
|
||||
}
|
||||
template <class Rep_, class Period_> void wait_for(const std::chrono::duration<Rep_, Period_> &Time)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
std::unique_lock lock(m_mutex);
|
||||
m_condition.wait_for(lock, Time, [this]() { return m_spurious == false; });
|
||||
}
|
||||
void notify_one()
|
||||
@@ -439,7 +439,7 @@ class condition_variable
|
||||
}
|
||||
void spurious(bool const Spurious)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_spurious = Spurious;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user