mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-17 23:17:34 +01:00
core/hle: Replace lock_guard with scoped_lock
This commit is contained in:
parent
c589db6add
commit
1f275eb077
@ -99,7 +99,7 @@ struct KernelCore::Impl {
|
|||||||
// Close all open server ports.
|
// Close all open server ports.
|
||||||
std::unordered_set<KServerPort*> server_ports_;
|
std::unordered_set<KServerPort*> server_ports_;
|
||||||
{
|
{
|
||||||
std::lock_guard lk(server_ports_lock);
|
std::scoped_lock lk{server_ports_lock};
|
||||||
server_ports_ = server_ports;
|
server_ports_ = server_ports;
|
||||||
server_ports.clear();
|
server_ports.clear();
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ struct KernelCore::Impl {
|
|||||||
|
|
||||||
// Close kernel objects that were not freed on shutdown
|
// Close kernel objects that were not freed on shutdown
|
||||||
{
|
{
|
||||||
std::lock_guard lk(registered_in_use_objects_lock);
|
std::scoped_lock lk{registered_in_use_objects_lock};
|
||||||
if (registered_in_use_objects.size()) {
|
if (registered_in_use_objects.size()) {
|
||||||
for (auto& object : registered_in_use_objects) {
|
for (auto& object : registered_in_use_objects) {
|
||||||
object->Close();
|
object->Close();
|
||||||
@ -178,7 +178,7 @@ struct KernelCore::Impl {
|
|||||||
|
|
||||||
// Track kernel objects that were not freed on shutdown
|
// Track kernel objects that were not freed on shutdown
|
||||||
{
|
{
|
||||||
std::lock_guard lk(registered_objects_lock);
|
std::scoped_lock lk{registered_objects_lock};
|
||||||
if (registered_objects.size()) {
|
if (registered_objects.size()) {
|
||||||
LOG_DEBUG(Kernel, "{} kernel objects were dangling on shutdown!",
|
LOG_DEBUG(Kernel, "{} kernel objects were dangling on shutdown!",
|
||||||
registered_objects.size());
|
registered_objects.size());
|
||||||
@ -660,7 +660,7 @@ struct KernelCore::Impl {
|
|||||||
|
|
||||||
KClientPort* port = &search->second(system.ServiceManager(), system);
|
KClientPort* port = &search->second(system.ServiceManager(), system);
|
||||||
{
|
{
|
||||||
std::lock_guard lk(server_ports_lock);
|
std::scoped_lock lk{server_ports_lock};
|
||||||
server_ports.insert(&port->GetParent()->GetServerPort());
|
server_ports.insert(&port->GetParent()->GetServerPort());
|
||||||
}
|
}
|
||||||
return port;
|
return port;
|
||||||
@ -929,22 +929,22 @@ KClientPort* KernelCore::CreateNamedServicePort(std::string name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KernelCore::RegisterKernelObject(KAutoObject* object) {
|
void KernelCore::RegisterKernelObject(KAutoObject* object) {
|
||||||
std::lock_guard lk(impl->registered_objects_lock);
|
std::scoped_lock lk{impl->registered_objects_lock};
|
||||||
impl->registered_objects.insert(object);
|
impl->registered_objects.insert(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KernelCore::UnregisterKernelObject(KAutoObject* object) {
|
void KernelCore::UnregisterKernelObject(KAutoObject* object) {
|
||||||
std::lock_guard lk(impl->registered_objects_lock);
|
std::scoped_lock lk{impl->registered_objects_lock};
|
||||||
impl->registered_objects.erase(object);
|
impl->registered_objects.erase(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KernelCore::RegisterInUseObject(KAutoObject* object) {
|
void KernelCore::RegisterInUseObject(KAutoObject* object) {
|
||||||
std::lock_guard lk(impl->registered_in_use_objects_lock);
|
std::scoped_lock lk{impl->registered_in_use_objects_lock};
|
||||||
impl->registered_in_use_objects.insert(object);
|
impl->registered_in_use_objects.insert(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KernelCore::UnregisterInUseObject(KAutoObject* object) {
|
void KernelCore::UnregisterInUseObject(KAutoObject* object) {
|
||||||
std::lock_guard lk(impl->registered_in_use_objects_lock);
|
std::scoped_lock lk{impl->registered_in_use_objects_lock};
|
||||||
impl->registered_in_use_objects.erase(object);
|
impl->registered_in_use_objects.erase(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ TimeManager::TimeManager(Core::System& system_) : system{system_} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TimeManager::ScheduleTimeEvent(KThread* thread, s64 nanoseconds) {
|
void TimeManager::ScheduleTimeEvent(KThread* thread, s64 nanoseconds) {
|
||||||
std::lock_guard lock{mutex};
|
std::scoped_lock lock{mutex};
|
||||||
if (nanoseconds > 0) {
|
if (nanoseconds > 0) {
|
||||||
ASSERT(thread);
|
ASSERT(thread);
|
||||||
ASSERT(thread->GetState() != ThreadState::Runnable);
|
ASSERT(thread->GetState() != ThreadState::Runnable);
|
||||||
@ -35,7 +35,7 @@ void TimeManager::ScheduleTimeEvent(KThread* thread, s64 nanoseconds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TimeManager::UnscheduleTimeEvent(KThread* thread) {
|
void TimeManager::UnscheduleTimeEvent(KThread* thread) {
|
||||||
std::lock_guard lock{mutex};
|
std::scoped_lock lock{mutex};
|
||||||
system.CoreTiming().UnscheduleEvent(time_manager_event_type,
|
system.CoreTiming().UnscheduleEvent(time_manager_event_type,
|
||||||
reinterpret_cast<uintptr_t>(thread));
|
reinterpret_cast<uintptr_t>(thread));
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ void Controller_NPad::OnRelease() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) {
|
void Controller_NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) {
|
||||||
std::lock_guard lock{mutex};
|
std::scoped_lock lock{mutex};
|
||||||
auto& controller = GetControllerFromNpadIdType(npad_id);
|
auto& controller = GetControllerFromNpadIdType(npad_id);
|
||||||
const auto controller_type = controller.device->GetNpadStyleIndex();
|
const auto controller_type = controller.device->GetNpadStyleIndex();
|
||||||
if (!controller.device->IsConnected()) {
|
if (!controller.device->IsConnected()) {
|
||||||
|
@ -14,7 +14,7 @@ HosBinderDriverServer::HosBinderDriverServer(Core::System& system_)
|
|||||||
HosBinderDriverServer::~HosBinderDriverServer() {}
|
HosBinderDriverServer::~HosBinderDriverServer() {}
|
||||||
|
|
||||||
u64 HosBinderDriverServer::RegisterProducer(std::unique_ptr<android::IBinder>&& binder) {
|
u64 HosBinderDriverServer::RegisterProducer(std::unique_ptr<android::IBinder>&& binder) {
|
||||||
std::lock_guard lk{lock};
|
std::scoped_lock lk{lock};
|
||||||
|
|
||||||
last_id++;
|
last_id++;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ u64 HosBinderDriverServer::RegisterProducer(std::unique_ptr<android::IBinder>&&
|
|||||||
}
|
}
|
||||||
|
|
||||||
android::IBinder* HosBinderDriverServer::TryGetProducer(u64 id) {
|
android::IBinder* HosBinderDriverServer::TryGetProducer(u64 id) {
|
||||||
std::lock_guard lk{lock};
|
std::scoped_lock lk{lock};
|
||||||
|
|
||||||
if (auto search = producers.find(id); search != producers.end()) {
|
if (auto search = producers.find(id); search != producers.end()) {
|
||||||
return search->second.get();
|
return search->second.get();
|
||||||
|
Loading…
Reference in New Issue
Block a user