diff options
author | bunnei <bunneidev@gmail.com> | 2021-04-22 06:43:25 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2021-05-06 01:40:52 +0200 |
commit | 0297448fbc6bf909b0bc061723c38208b9667b66 (patch) | |
tree | 7c21303536466b0a76331e4274ecb3e12eb40421 /src/core/hle/kernel/k_client_port.cpp | |
parent | hle: kernel: HandleTable: Remove deprecated APIs. (diff) | |
download | yuzu-0297448fbc6bf909b0bc061723c38208b9667b66.tar yuzu-0297448fbc6bf909b0bc061723c38208b9667b66.tar.gz yuzu-0297448fbc6bf909b0bc061723c38208b9667b66.tar.bz2 yuzu-0297448fbc6bf909b0bc061723c38208b9667b66.tar.lz yuzu-0297448fbc6bf909b0bc061723c38208b9667b66.tar.xz yuzu-0297448fbc6bf909b0bc061723c38208b9667b66.tar.zst yuzu-0297448fbc6bf909b0bc061723c38208b9667b66.zip |
Diffstat (limited to 'src/core/hle/kernel/k_client_port.cpp')
-rw-r--r-- | src/core/hle/kernel/k_client_port.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_client_port.cpp b/src/core/hle/kernel/k_client_port.cpp new file mode 100644 index 000000000..15bf0d4fc --- /dev/null +++ b/src/core/hle/kernel/k_client_port.cpp @@ -0,0 +1,58 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/hle/kernel/hle_ipc.h" +#include "core/hle/kernel/k_client_port.h" +#include "core/hle/kernel/k_session.h" +#include "core/hle/kernel/object.h" +#include "core/hle/kernel/server_port.h" +#include "core/hle/kernel/svc_results.h" + +namespace Kernel { + +KClientPort::KClientPort(KernelCore& kernel) : KSynchronizationObject{kernel} {} +KClientPort::~KClientPort() = default; + +void KClientPort::Initialize(s32 max_sessions_, std::string&& name_) { + max_sessions = max_sessions_; + name = std::move(name_); +} + +std::shared_ptr<ServerPort> KClientPort::GetServerPort() const { + return server_port; +} + +ResultVal<KClientSession*> KClientPort::Connect() { + if (num_sessions >= max_sessions) { + return ResultOutOfSessions; + } + num_sessions++; + + auto* session = Kernel::KSession::Create(kernel); + session->Initialize(name + ":ClientPort"); + + if (server_port->HasHLEHandler()) { + server_port->GetHLEHandler()->ClientConnected(session); + } else { + server_port->AppendPendingSession(std::addressof(session->GetServerSession())); + } + + return MakeResult(std::addressof(session->GetClientSession())); +} + +void KClientPort::ConnectionClosed() { + if (num_sessions == 0) { + return; + } + + --num_sessions; +} + +void KClientPort::Destroy() {} + +bool KClientPort::IsSignaled() const { + return num_sessions < max_sessions; +} + +} // namespace Kernel |