summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/time/system_clock_context_update_callback.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-12-22 23:49:51 +0100
committerbunnei <bunneidev@gmail.com>2020-01-04 19:48:29 +0100
commit78f977c980e125e92b86261335447d0a254f18ee (patch)
treeeca0bcfdcabe32dd737fc545b1ce42395cdad2fc /src/core/hle/service/time/system_clock_context_update_callback.cpp
parentcore: Initialize several structs that make use of Common::UUID. (diff)
downloadyuzu-78f977c980e125e92b86261335447d0a254f18ee.tar
yuzu-78f977c980e125e92b86261335447d0a254f18ee.tar.gz
yuzu-78f977c980e125e92b86261335447d0a254f18ee.tar.bz2
yuzu-78f977c980e125e92b86261335447d0a254f18ee.tar.lz
yuzu-78f977c980e125e92b86261335447d0a254f18ee.tar.xz
yuzu-78f977c980e125e92b86261335447d0a254f18ee.tar.zst
yuzu-78f977c980e125e92b86261335447d0a254f18ee.zip
Diffstat (limited to 'src/core/hle/service/time/system_clock_context_update_callback.cpp')
-rw-r--r--src/core/hle/service/time/system_clock_context_update_callback.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/core/hle/service/time/system_clock_context_update_callback.cpp b/src/core/hle/service/time/system_clock_context_update_callback.cpp
new file mode 100644
index 000000000..5cdb80703
--- /dev/null
+++ b/src/core/hle/service/time/system_clock_context_update_callback.cpp
@@ -0,0 +1,55 @@
+// Copyright 2019 yuzu emulator team
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include "core/hle/kernel/writable_event.h"
+#include "core/hle/service/time/errors.h"
+#include "core/hle/service/time/system_clock_context_update_callback.h"
+
+namespace Service::Time::Clock {
+
+SystemClockContextUpdateCallback::SystemClockContextUpdateCallback() = default;
+SystemClockContextUpdateCallback::~SystemClockContextUpdateCallback() = default;
+
+bool SystemClockContextUpdateCallback::NeedUpdate(const SystemClockContext& value) const {
+ if (has_context) {
+ return context.offset != value.offset ||
+ context.steady_time_point.clock_source_id != value.steady_time_point.clock_source_id;
+ }
+
+ return true;
+}
+
+void SystemClockContextUpdateCallback::RegisterOperationEvent(
+ std::shared_ptr<Kernel::WritableEvent>&& writable_event) {
+ operation_event_list.emplace_back(std::move(writable_event));
+}
+
+void SystemClockContextUpdateCallback::BroadcastOperationEvent() {
+ for (const auto& writable_event : operation_event_list) {
+ writable_event->Signal();
+ }
+}
+
+ResultCode SystemClockContextUpdateCallback::Update(const SystemClockContext& value) {
+ ResultCode result{RESULT_SUCCESS};
+
+ if (NeedUpdate(value)) {
+ context = value;
+ has_context = true;
+
+ result = Update();
+
+ if (result == RESULT_SUCCESS) {
+ BroadcastOperationEvent();
+ }
+ }
+
+ return result;
+}
+
+ResultCode SystemClockContextUpdateCallback::Update() {
+ return RESULT_SUCCESS;
+}
+
+} // namespace Service::Time::Clock