summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/synchronization.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-02-14 20:40:20 +0100
committerGitHub <noreply@github.com>2020-02-14 20:40:20 +0100
commitf552d553bac1374c583d748dad27f8c86e86c4a0 (patch)
tree1da4aa037ff417fa4fd43bffac267dcb2b55a72d /src/core/hle/kernel/synchronization.h
parentMerge pull request #3379 from ReinUsesLisp/cbuf-offset (diff)
parentCore: Correct compilition in GCC (diff)
downloadyuzu-f552d553bac1374c583d748dad27f8c86e86c4a0.tar
yuzu-f552d553bac1374c583d748dad27f8c86e86c4a0.tar.gz
yuzu-f552d553bac1374c583d748dad27f8c86e86c4a0.tar.bz2
yuzu-f552d553bac1374c583d748dad27f8c86e86c4a0.tar.lz
yuzu-f552d553bac1374c583d748dad27f8c86e86c4a0.tar.xz
yuzu-f552d553bac1374c583d748dad27f8c86e86c4a0.tar.zst
yuzu-f552d553bac1374c583d748dad27f8c86e86c4a0.zip
Diffstat (limited to 'src/core/hle/kernel/synchronization.h')
-rw-r--r--src/core/hle/kernel/synchronization.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/core/hle/kernel/synchronization.h b/src/core/hle/kernel/synchronization.h
new file mode 100644
index 000000000..379f4b1d3
--- /dev/null
+++ b/src/core/hle/kernel/synchronization.h
@@ -0,0 +1,44 @@
+// Copyright 2020 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <memory>
+#include <utility>
+#include <vector>
+
+#include "core/hle/kernel/object.h"
+#include "core/hle/result.h"
+
+namespace Core {
+class System;
+} // namespace Core
+
+namespace Kernel {
+
+class SynchronizationObject;
+
+/**
+ * The 'Synchronization' class is an interface for handling synchronization methods
+ * used by Synchronization objects and synchronization SVCs. This centralizes processing of
+ * such
+ */
+class Synchronization {
+public:
+ explicit Synchronization(Core::System& system);
+
+ /// Signals a synchronization object, waking up all its waiting threads
+ void SignalObject(SynchronizationObject& obj) const;
+
+ /// Tries to see if waiting for any of the sync_objects is necessary, if not
+ /// it returns Success and the handle index of the signaled sync object. In
+ /// case not, the current thread will be locked and wait for nano_seconds or
+ /// for a synchronization object to signal.
+ std::pair<ResultCode, Handle> WaitFor(
+ std::vector<std::shared_ptr<SynchronizationObject>>& sync_objects, s64 nano_seconds);
+
+private:
+ Core::System& system;
+};
+} // namespace Kernel