mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2025-08-11 11:32:33 -07:00
Rework time service to fix time passing offline.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user