summaryrefslogtreecommitdiff
path: root/src/core/hle/service/time
diff options
context:
space:
mode:
authorGravatar Morph2021-09-28 23:42:50 -0400
committerGravatar Morph2021-10-01 23:38:59 -0400
commitfadcee14f8fca1b76b4ea48b1cfd136ccae8d182 (patch)
treea5787938bc73ff1b0b539e0945d3544d06a7d6d2 /src/core/hle/service/time
parentMerge pull request #7102 from Morph1984/remove-boxcat (diff)
downloadyuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.gz
yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.xz
yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.zip
service: Replace service event creation with ServiceContext::CreateEvent
The service context helps to manage all created events and allows us to close them upon destruction.
Diffstat (limited to 'src/core/hle/service/time')
-rw-r--r--src/core/hle/service/time/standard_user_system_clock_core.cpp14
-rw-r--r--src/core/hle/service/time/standard_user_system_clock_core.h7
2 files changed, 15 insertions, 6 deletions
diff --git a/src/core/hle/service/time/standard_user_system_clock_core.cpp b/src/core/hle/service/time/standard_user_system_clock_core.cpp
index ef79ab917..e94220a44 100644
--- a/src/core/hle/service/time/standard_user_system_clock_core.cpp
+++ b/src/core/hle/service/time/standard_user_system_clock_core.cpp
@@ -4,6 +4,7 @@
4 4
5#include "common/assert.h" 5#include "common/assert.h"
6#include "core/core.h" 6#include "core/core.h"
7#include "core/hle/kernel/k_event.h"
7#include "core/hle/service/time/standard_local_system_clock_core.h" 8#include "core/hle/service/time/standard_local_system_clock_core.h"
8#include "core/hle/service/time/standard_network_system_clock_core.h" 9#include "core/hle/service/time/standard_network_system_clock_core.h"
9#include "core/hle/service/time/standard_user_system_clock_core.h" 10#include "core/hle/service/time/standard_user_system_clock_core.h"
@@ -16,10 +17,15 @@ StandardUserSystemClockCore::StandardUserSystemClockCore(
16 : SystemClockCore(local_system_clock_core_.GetSteadyClockCore()), 17 : SystemClockCore(local_system_clock_core_.GetSteadyClockCore()),
17 local_system_clock_core{local_system_clock_core_}, 18 local_system_clock_core{local_system_clock_core_},
18 network_system_clock_core{network_system_clock_core_}, 19 network_system_clock_core{network_system_clock_core_},
19 auto_correction_time{SteadyClockTimePoint::GetRandom()}, auto_correction_event{ 20 auto_correction_time{SteadyClockTimePoint::GetRandom()}, service_context{
20 system_.Kernel()} { 21 system_,
21 Kernel::KAutoObject::Create(std::addressof(auto_correction_event)); 22 "StandardUserSystemClockCore"} {
22 auto_correction_event.Initialize("StandardUserSystemClockCore:AutoCorrectionEvent"); 23 auto_correction_event =
24 service_context.CreateEvent("StandardUserSystemClockCore:AutoCorrectionEvent");
25}
26
27StandardUserSystemClockCore::~StandardUserSystemClockCore() {
28 service_context.CloseEvent(auto_correction_event);
23} 29}
24 30
25ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::System& system, 31ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::System& system,
diff --git a/src/core/hle/service/time/standard_user_system_clock_core.h b/src/core/hle/service/time/standard_user_system_clock_core.h
index bf9ec5e42..b7cb2b045 100644
--- a/src/core/hle/service/time/standard_user_system_clock_core.h
+++ b/src/core/hle/service/time/standard_user_system_clock_core.h
@@ -4,7 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "core/hle/kernel/k_event.h" 7#include "core/hle/service/kernel_helpers.h"
8#include "core/hle/service/time/clock_types.h" 8#include "core/hle/service/time/clock_types.h"
9#include "core/hle/service/time/system_clock_core.h" 9#include "core/hle/service/time/system_clock_core.h"
10 10
@@ -27,6 +27,8 @@ public:
27 StandardNetworkSystemClockCore& network_system_clock_core_, 27 StandardNetworkSystemClockCore& network_system_clock_core_,
28 Core::System& system_); 28 Core::System& system_);
29 29
30 ~StandardUserSystemClockCore() override;
31
30 ResultCode SetAutomaticCorrectionEnabled(Core::System& system, bool value); 32 ResultCode SetAutomaticCorrectionEnabled(Core::System& system, bool value);
31 33
32 ResultCode GetClockContext(Core::System& system, SystemClockContext& ctx) const override; 34 ResultCode GetClockContext(Core::System& system, SystemClockContext& ctx) const override;
@@ -55,7 +57,8 @@ private:
55 StandardNetworkSystemClockCore& network_system_clock_core; 57 StandardNetworkSystemClockCore& network_system_clock_core;
56 bool auto_correction_enabled{}; 58 bool auto_correction_enabled{};
57 SteadyClockTimePoint auto_correction_time; 59 SteadyClockTimePoint auto_correction_time;
58 Kernel::KEvent auto_correction_event; 60 KernelHelpers::ServiceContext service_context;
61 Kernel::KEvent* auto_correction_event;
59}; 62};
60 63
61} // namespace Service::Time::Clock 64} // namespace Service::Time::Clock