Rework time service to fix time passing offline.

This commit is contained in:
Kelebek1 2023-10-29 13:50:55 +00:00
parent a560b9f5a2
commit e4915fb7d2
144 changed files with 8734 additions and 3972 deletions

View file

@ -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());
}