diff options
author | bunnei <bunneidev@gmail.com> | 2021-05-01 21:48:41 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2021-05-06 01:40:53 +0200 |
commit | f6d45b747e37ed1871d9155fbf2d3d5099e1c1b8 (patch) | |
tree | 6cbdec08fa1006a4fd9ba21a6fe9a97ba8b47e81 /src/core/hle/kernel | |
parent | fixup! hle: kernel: Migrate KSession, KClientSession, and KServerSession to KAutoObject. (diff) | |
download | yuzu-f6d45b747e37ed1871d9155fbf2d3d5099e1c1b8.tar yuzu-f6d45b747e37ed1871d9155fbf2d3d5099e1c1b8.tar.gz yuzu-f6d45b747e37ed1871d9155fbf2d3d5099e1c1b8.tar.bz2 yuzu-f6d45b747e37ed1871d9155fbf2d3d5099e1c1b8.tar.lz yuzu-f6d45b747e37ed1871d9155fbf2d3d5099e1c1b8.tar.xz yuzu-f6d45b747e37ed1871d9155fbf2d3d5099e1c1b8.tar.zst yuzu-f6d45b747e37ed1871d9155fbf2d3d5099e1c1b8.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/kernel/k_server_session.h | 4 | ||||
-rw-r--r-- | src/core/hle/kernel/k_session.cpp | 24 | ||||
-rw-r--r-- | src/core/hle/kernel/k_session.h | 22 |
3 files changed, 28 insertions, 22 deletions
diff --git a/src/core/hle/kernel/k_server_session.h b/src/core/hle/kernel/k_server_session.h index 4a54e6634..77095bb85 100644 --- a/src/core/hle/kernel/k_server_session.h +++ b/src/core/hle/kernel/k_server_session.h @@ -47,11 +47,11 @@ public: void Initialize(KSession* parent_, std::string&& name_); - constexpr KSession* GetParent() { + KSession* GetParent() { return parent; } - constexpr const KSession* GetParent() const { + const KSession* GetParent() const { return parent; } diff --git a/src/core/hle/kernel/k_session.cpp b/src/core/hle/kernel/k_session.cpp index 5e629d446..7b0bc177d 100644 --- a/src/core/hle/kernel/k_session.cpp +++ b/src/core/hle/kernel/k_session.cpp @@ -49,24 +49,30 @@ void KSession::Initialize(KClientPort* port_, const std::string& name_) { } void KSession::Finalize() { - if (port != nullptr) { - port->OnSessionFinalized(); - port->Close(); + if (port == nullptr) { + return; } + + port->OnSessionFinalized(); + port->Close(); } void KSession::OnServerClosed() { - if (GetState() == State::Normal) { - SetState(State::ServerClosed); - client.OnServerClosed(); + if (GetState() != State::Normal) { + return; } + + SetState(State::ServerClosed); + client.OnServerClosed(); } void KSession::OnClientClosed() { - if (GetState() == State::Normal) { - SetState(State::ClientClosed); - server.OnClientClosed(); + if (GetState() != State::Normal) { + return; } + + SetState(State::ClientClosed); + server.OnClientClosed(); } void KSession::PostDestroy(uintptr_t arg) { diff --git a/src/core/hle/kernel/k_session.h b/src/core/hle/kernel/k_session.h index d50e21f3f..4321b7885 100644 --- a/src/core/hle/kernel/k_session.h +++ b/src/core/hle/kernel/k_session.h @@ -16,14 +16,6 @@ namespace Kernel { class KSession final : public KAutoObjectWithSlabHeapAndContainer<KSession, KAutoObjectWithList> { KERNEL_AUTOOBJECT_TRAITS(KSession, KAutoObject); -private: - enum class State : u8 { - Invalid = 0, - Normal = 1, - ClientClosed = 2, - ServerClosed = 3, - }; - public: explicit KSession(KernelCore& kernel); virtual ~KSession() override; @@ -75,19 +67,27 @@ public: } private: + enum class State : u8 { + Invalid = 0, + Normal = 1, + ClientClosed = 2, + ServerClosed = 3, + }; + +private: void SetState(State state) { atomic_state = static_cast<u8>(state); } State GetState() const { - return static_cast<State>(atomic_state.load()); + return static_cast<State>(atomic_state.load(std::memory_order_relaxed)); } private: KServerSession server; KClientSession client; - std::atomic<std::underlying_type<State>::type> atomic_state{ - static_cast<std::underlying_type<State>::type>(State::Invalid)}; + std::atomic<std::underlying_type_t<State>> atomic_state{ + static_cast<std::underlying_type_t<State>>(State::Invalid)}; KClientPort* port{}; KProcess* process{}; bool initialized{}; |