summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/sm
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service/sm')
-rw-r--r--src/core/hle/service/sm/sm.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h
index 4ae32a9c1..32c218638 100644
--- a/src/core/hle/service/sm/sm.h
+++ b/src/core/hle/service/sm/sm.h
@@ -3,6 +3,7 @@
#pragma once
+#include <chrono>
#include <memory>
#include <mutex>
#include <string>
@@ -10,6 +11,7 @@
#include "common/concepts.h"
#include "core/hle/kernel/k_port.h"
+#include "core/hle/kernel/svc.h"
#include "core/hle/result.h"
#include "core/hle/service/service.h"
@@ -62,12 +64,21 @@ public:
Result GetServicePort(Kernel::KClientPort** out_client_port, const std::string& name);
template <Common::DerivedFrom<SessionRequestHandler> T>
- std::shared_ptr<T> GetService(const std::string& service_name) const {
+ std::shared_ptr<T> GetService(const std::string& service_name, bool block = false) const {
auto service = registered_services.find(service_name);
- if (service == registered_services.end()) {
+ if (service == registered_services.end() && !block) {
LOG_DEBUG(Service, "Can't find service: {}", service_name);
return nullptr;
+ } else if (block) {
+ using namespace std::literals::chrono_literals;
+ while (service == registered_services.end()) {
+ Kernel::Svc::SleepThread(
+ kernel.System(),
+ std::chrono::duration_cast<std::chrono::nanoseconds>(100ms).count());
+ service = registered_services.find(service_name);
+ }
}
+
return std::static_pointer_cast<T>(service->second());
}