suyu/src/core/hle/kernel/k_server_port.h
Morph 99ceb03a1c general: Convert source file copyright comments over to SPDX
This formats all copyright comments according to SPDX formatting guidelines.
Additionally, this resolves the remaining GPLv2 only licensed files by relicensing them to GPLv2.0-or-later.
2022-04-23 05:55:32 -04:00

72 lines
1.8 KiB
C++

// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include <string>
#include <utility>
#include <boost/intrusive/list.hpp>
#include "core/hle/kernel/k_server_session.h"
#include "core/hle/kernel/k_synchronization_object.h"
namespace Kernel {
class KernelCore;
class KPort;
class SessionRequestHandler;
class KServerPort final : public KSynchronizationObject {
KERNEL_AUTOOBJECT_TRAITS(KServerPort, KSynchronizationObject);
public:
explicit KServerPort(KernelCore& kernel_);
~KServerPort() override;
void Initialize(KPort* parent_port_, std::string&& name_);
/// Whether or not this server port has an HLE handler available.
bool HasSessionRequestHandler() const {
return !session_handler.expired();
}
/// Gets the HLE handler for this port.
SessionRequestHandlerWeakPtr GetSessionRequestHandler() const {
return session_handler;
}
/**
* Sets the HLE handler template for the port. ServerSessions crated by connecting to this port
* will inherit a reference to this handler.
*/
void SetSessionHandler(SessionRequestHandlerWeakPtr&& handler) {
session_handler = std::move(handler);
}
void EnqueueSession(KServerSession* pending_session);
KServerSession* AcceptSession();
const KPort* GetParent() const {
return parent;
}
bool IsLight() const;
// Overridden virtual functions.
void Destroy() override;
bool IsSignaled() const override;
private:
using SessionList = boost::intrusive::list<KServerSession>;
void CleanupSessions();
SessionList session_list;
SessionRequestHandlerWeakPtr session_handler;
KPort* parent{};
};
} // namespace Kernel