mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 04:27:42 +00:00
General: Make use of lock deduction guides
Allows dehardcoding the type within the locks.
This commit is contained in:
@@ -118,7 +118,7 @@ static std::mutex PathsMutex;
|
||||
static std::unordered_map<std::thread::id, ProjectPath> PathsInProgress;
|
||||
|
||||
bool ResourceLock::InProgress(const ProjectPath& path) {
|
||||
std::unique_lock<std::mutex> lk(PathsMutex);
|
||||
std::unique_lock lk{PathsMutex};
|
||||
for (const auto& p : PathsInProgress)
|
||||
if (p.second == path)
|
||||
return true;
|
||||
@@ -126,7 +126,7 @@ bool ResourceLock::InProgress(const ProjectPath& path) {
|
||||
}
|
||||
|
||||
bool ResourceLock::SetThreadRes(const ProjectPath& path) {
|
||||
std::unique_lock<std::mutex> lk(PathsMutex);
|
||||
std::unique_lock lk{PathsMutex};
|
||||
if (PathsInProgress.find(std::this_thread::get_id()) != PathsInProgress.cend())
|
||||
LogModule.report(logvisor::Fatal, fmt("multiple resource locks on thread"));
|
||||
|
||||
@@ -139,7 +139,7 @@ bool ResourceLock::SetThreadRes(const ProjectPath& path) {
|
||||
}
|
||||
|
||||
void ResourceLock::ClearThreadRes() {
|
||||
std::unique_lock<std::mutex> lk(PathsMutex);
|
||||
std::unique_lock lk{PathsMutex};
|
||||
PathsInProgress.erase(std::this_thread::get_id());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user