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);
// Register EmuHandle
EmuHandleLookupLock.lock();
EmuHandleLookup.emplace(EmuHandleToHandle(emuHandle), emuHandle);
EmuHandleLookupLock.unlock();
{
const std::lock_guard<std::mutex> scopedLock(EmuHandleLookupLock);
EmuHandleLookup.emplace(EmuHandleToHandle(emuHandle), emuHandle);
}
return emuHandle;
}
@ -275,9 +276,8 @@ NTSTATUS EmuHandle::NtClose()
// Unregister the handle
if (status == STATUS_SUCCESS) {
EmuHandleLookupLock.lock();
const std::lock_guard<std::mutex> scopedLock(EmuHandleLookupLock);
EmuHandleLookup.erase(EmuHandleToHandle(this));
EmuHandleLookupLock.unlock();
}
return status;