yuzu/src/core/hle/kernel/k_shared_memory_info.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.0 KiB
C++
Raw Normal View History

// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2021-09-25 17:01:53 +02:00
#pragma once
2023-04-29 21:10:09 +02:00
#include "common/intrusive_list.h"
2021-09-25 17:01:53 +02:00
#include "core/hle/kernel/slab_helpers.h"
namespace Kernel {
class KSharedMemory;
class KSharedMemoryInfo final : public KSlabAllocated<KSharedMemoryInfo>,
2023-04-29 21:10:09 +02:00
public Common::IntrusiveListBaseNode<KSharedMemoryInfo> {
2021-09-25 17:01:53 +02:00
public:
2022-10-15 03:24:25 +02:00
explicit KSharedMemoryInfo(KernelCore&) {}
KSharedMemoryInfo() = default;
2021-09-25 17:01:53 +02:00
constexpr void Initialize(KSharedMemory* m) {
m_shared_memory = m;
m_reference_count = 0;
2021-09-25 17:01:53 +02:00
}
constexpr KSharedMemory* GetSharedMemory() const {
return m_shared_memory;
2021-09-25 17:01:53 +02:00
}
constexpr void Open() {
++m_reference_count;
ASSERT(m_reference_count > 0);
2021-09-25 17:01:53 +02:00
}
constexpr bool Close() {
ASSERT(m_reference_count > 0);
return (--m_reference_count) == 0;
2021-09-25 17:01:53 +02:00
}
private:
KSharedMemory* m_shared_memory{};
size_t m_reference_count{};
2021-09-25 17:01:53 +02:00
};
} // namespace Kernel