mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-08-22 23:50:32 +00:00
3aa0d46259
reworked a bit to remove references of parent objects and instead pass as arguments to methods to prevent useless reloads Signed-off-by: lizzie <lizzie@eden-emu.dev> Co-authored-by: maufeat <sahyno1996@gmail.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3908 Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: crueter <crueter@eden-emu.dev>
100 lines
2.4 KiB
C++
100 lines
2.4 KiB
C++
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <atomic>
|
|
#include <string>
|
|
|
|
#include "core/hle/kernel/k_client_session.h"
|
|
#include "core/hle/kernel/k_server_session.h"
|
|
#include "core/hle/kernel/slab_helpers.h"
|
|
|
|
namespace Kernel {
|
|
|
|
class SessionRequestManager;
|
|
|
|
class KSession final : public KAutoObjectWithSlabHeapAndContainer<KSession, KAutoObjectWithList> {
|
|
KERNEL_AUTOOBJECT_TRAITS(KSession, KAutoObject);
|
|
|
|
public:
|
|
explicit KSession(KernelCore& kernel);
|
|
~KSession() override;
|
|
|
|
void Initialize(KernelCore& kernel, KClientPort* port, uintptr_t name);
|
|
void Finalize(KernelCore& kernel) override;
|
|
|
|
bool IsInitialized() const override {
|
|
return m_initialized;
|
|
}
|
|
|
|
uintptr_t GetPostDestroyArgument() const override {
|
|
return reinterpret_cast<uintptr_t>(m_process);
|
|
}
|
|
|
|
static void PostDestroy(KernelCore& kernel, uintptr_t arg);
|
|
void OnServerClosed(KernelCore& kernel);
|
|
void OnClientClosed(KernelCore& kernel);
|
|
|
|
bool IsServerClosed() const {
|
|
return this->GetState() != State::Normal;
|
|
}
|
|
|
|
bool IsClientClosed() const {
|
|
return this->GetState() != State::Normal;
|
|
}
|
|
|
|
Result OnRequest(KernelCore& kernel, KSessionRequest* request) {
|
|
R_RETURN(m_server.OnRequest(kernel, request));
|
|
}
|
|
|
|
KClientSession& GetClientSession() {
|
|
return m_client;
|
|
}
|
|
|
|
KServerSession& GetServerSession() {
|
|
return m_server;
|
|
}
|
|
|
|
const KClientSession& GetClientSession() const {
|
|
return m_client;
|
|
}
|
|
|
|
const KServerSession& GetServerSession() const {
|
|
return m_server;
|
|
}
|
|
|
|
const KClientPort* GetParent() const {
|
|
return m_port;
|
|
}
|
|
|
|
private:
|
|
enum class State : u8 {
|
|
Invalid = 0,
|
|
Normal = 1,
|
|
ClientClosed = 2,
|
|
ServerClosed = 3,
|
|
};
|
|
|
|
void SetState(State state) {
|
|
m_atomic_state = static_cast<u8>(state);
|
|
}
|
|
|
|
State GetState() const {
|
|
return static_cast<State>(m_atomic_state.load());
|
|
}
|
|
|
|
KServerSession m_server;
|
|
KClientSession m_client;
|
|
KClientPort* m_port{};
|
|
uintptr_t m_name{};
|
|
KProcess* m_process{};
|
|
std::atomic<u8> m_atomic_state{static_cast<u8>(State::Invalid)};
|
|
bool m_initialized{};
|
|
};
|
|
|
|
} // namespace Kernel
|