blob: 2d8ff20d6df2f41619663d323dbf97e3fd8b682d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/intrusive_list.h"
#include "core/hle/kernel/slab_helpers.h"
namespace Kernel {
class KSharedMemory;
class KSharedMemoryInfo final : public KSlabAllocated<KSharedMemoryInfo>,
public Common::IntrusiveListBaseNode<KSharedMemoryInfo> {
public:
explicit KSharedMemoryInfo(KernelCore&) {}
KSharedMemoryInfo() = default;
constexpr void Initialize(KSharedMemory* m) {
m_shared_memory = m;
m_reference_count = 0;
}
constexpr KSharedMemory* GetSharedMemory() const {
return m_shared_memory;
}
constexpr void Open() {
++m_reference_count;
ASSERT(m_reference_count > 0);
}
constexpr bool Close() {
ASSERT(m_reference_count > 0);
return (--m_reference_count) == 0;
}
private:
KSharedMemory* m_shared_memory{};
size_t m_reference_count{};
};
} // namespace Kernel
|