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

43 lines
912 B
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
#include <boost/intrusive/list.hpp>
#include "core/hle/kernel/slab_helpers.h"
namespace Kernel {
class KSharedMemory;
class KSharedMemoryInfo final : public KSlabAllocated<KSharedMemoryInfo>,
public boost::intrusive::list_base_hook<> {
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* 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