mirror of https://github.com/AxioDL/metaforce.git
hecl/hecl: Simplify SetThreadRes()
This commit is contained in:
parent
32fec587b5
commit
bc7a6563cf
|
@ -135,14 +135,17 @@ bool ResourceLock::InProgress(const ProjectPath& path) {
|
|||
|
||||
bool ResourceLock::SetThreadRes(const ProjectPath& path) {
|
||||
std::unique_lock lk{PathsMutex};
|
||||
if (PathsInProgress.find(std::this_thread::get_id()) != PathsInProgress.cend())
|
||||
if (PathsInProgress.find(std::this_thread::get_id()) != PathsInProgress.cend()) {
|
||||
LogModule.report(logvisor::Fatal, fmt("multiple resource locks on thread"));
|
||||
}
|
||||
|
||||
for (const auto& p : PathsInProgress)
|
||||
if (p.second == path)
|
||||
const bool isInProgress = std::any_of(PathsInProgress.cbegin(), PathsInProgress.cend(),
|
||||
[&path](const auto& entry) { return entry.second == path; });
|
||||
if (isInProgress) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PathsInProgress[std::this_thread::get_id()] = path;
|
||||
PathsInProgress.insert_or_assign(std::this_thread::get_id(), path);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue