diff options
author | Ameer J <52414509+ameerj@users.noreply.github.com> | 2021-10-04 06:09:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-04 06:09:08 +0200 |
commit | 01f79d638fbbca54280ab9b5840e5a483b7ceb69 (patch) | |
tree | 6520b5f70f2d3132031610e39d6d7c50aa268838 /src/core/hle/kernel/k_shared_memory_info.h | |
parent | Merge pull request #7122 from Morph1984/update-qt (diff) | |
parent | Fix KShareMemory object leak (diff) | |
download | yuzu-01f79d638fbbca54280ab9b5840e5a483b7ceb69.tar yuzu-01f79d638fbbca54280ab9b5840e5a483b7ceb69.tar.gz yuzu-01f79d638fbbca54280ab9b5840e5a483b7ceb69.tar.bz2 yuzu-01f79d638fbbca54280ab9b5840e5a483b7ceb69.tar.lz yuzu-01f79d638fbbca54280ab9b5840e5a483b7ceb69.tar.xz yuzu-01f79d638fbbca54280ab9b5840e5a483b7ceb69.tar.zst yuzu-01f79d638fbbca54280ab9b5840e5a483b7ceb69.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/kernel/k_shared_memory_info.h | 46 |
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 |