summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_shared_memory_info.h
diff options
context:
space:
mode:
authorFeng Chen <vonchenplus@gmail.com>2021-09-25 17:01:53 +0200
committerFeng Chen <vonchenplus@gmail.com>2021-09-29 03:51:20 +0200
commit5fbfc4c19eaca2ad88bf34ec33d068ffab6fe672 (patch)
tree95a899841bb6e1505372f5994bda3537ee2f940a /src/core/hle/kernel/k_shared_memory_info.h
parentFix KScopedAutoObject object leak when SendSyncRequest (diff)
downloadyuzu-5fbfc4c19eaca2ad88bf34ec33d068ffab6fe672.tar
yuzu-5fbfc4c19eaca2ad88bf34ec33d068ffab6fe672.tar.gz
yuzu-5fbfc4c19eaca2ad88bf34ec33d068ffab6fe672.tar.bz2
yuzu-5fbfc4c19eaca2ad88bf34ec33d068ffab6fe672.tar.lz
yuzu-5fbfc4c19eaca2ad88bf34ec33d068ffab6fe672.tar.xz
yuzu-5fbfc4c19eaca2ad88bf34ec33d068ffab6fe672.tar.zst
yuzu-5fbfc4c19eaca2ad88bf34ec33d068ffab6fe672.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/k_shared_memory_info.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_shared_memory_info.h b/src/core/hle/kernel/k_shared_memory_info.h
new file mode 100644
index 000000000..bf97a0184
--- /dev/null
+++ b/src/core/hle/kernel/k_shared_memory_info.h
@@ -0,0 +1,46 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <memory>
+#include <string>
+
+#include <boost/intrusive/list.hpp>
+
+#include "common/assert.h"
+#include "core/hle/kernel/slab_helpers.h"
+
+namespace Kernel {
+
+class KSharedMemory;
+
+class KSharedMemoryInfo final : public KSlabAllocated<KSharedMemoryInfo>,
+ public boost::intrusive::list_base_hook<> {
+
+public:
+ explicit KSharedMemoryInfo() = default;
+
+ constexpr void Initialize(KSharedMemory* shmem) {
+ shared_memory = shmem;
+ }
+
+ constexpr KSharedMemory* GetSharedMemory() const {
+ return shared_memory;
+ }
+
+ constexpr void Open() {
+ ++reference_count;
+ }
+
+ constexpr bool Close() {
+ return (--reference_count) == 0;
+ }
+
+private:
+ KSharedMemory* shared_memory{};
+ size_t reference_count{};
+};
+
+} // namespace Kernel