Use lock_guard instead of explicit lock/unlock

This commit is contained in:
Anthony 2021-02-25 21:38:24 +13:00
parent 3dd4ca7349
commit 7c51e2e34b
1 changed files with 5 additions and 5 deletions

View File

@ -262,9 +262,10 @@ EmuHandle* EmuHandle::CreateEmuHandle(EmuNtObject* ntObject) {
auto emuHandle = new EmuHandle(ntObject); auto emuHandle = new EmuHandle(ntObject);
// Register EmuHandle // Register EmuHandle
EmuHandleLookupLock.lock(); {
const std::lock_guard<std::mutex> scopedLock(EmuHandleLookupLock);
EmuHandleLookup.emplace(EmuHandleToHandle(emuHandle), emuHandle); EmuHandleLookup.emplace(EmuHandleToHandle(emuHandle), emuHandle);
EmuHandleLookupLock.unlock(); }
return emuHandle; return emuHandle;
} }
@ -275,9 +276,8 @@ NTSTATUS EmuHandle::NtClose()
// Unregister the handle // Unregister the handle
if (status == STATUS_SUCCESS) { if (status == STATUS_SUCCESS) {
EmuHandleLookupLock.lock(); const std::lock_guard<std::mutex> scopedLock(EmuHandleLookupLock);
EmuHandleLookup.erase(EmuHandleToHandle(this)); EmuHandleLookup.erase(EmuHandleToHandle(this));
EmuHandleLookupLock.unlock();
} }
return status; return status;