2016-05-22 18:22:49 +02:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-12-05 18:05:00 +01:00
|
|
|
#include <memory>
|
2016-05-22 18:22:49 +02:00
|
|
|
#include <string>
|
2016-05-22 19:30:13 +02:00
|
|
|
#include <tuple>
|
2016-05-22 18:22:49 +02:00
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "core/hle/kernel/kernel.h"
|
|
|
|
|
2016-12-05 17:02:08 +01:00
|
|
|
namespace Service {
|
|
|
|
class SessionRequestHandler;
|
|
|
|
}
|
|
|
|
|
2016-05-22 18:22:49 +02:00
|
|
|
namespace Kernel {
|
|
|
|
|
2016-05-22 19:30:13 +02:00
|
|
|
class ClientPort;
|
|
|
|
|
2016-05-22 18:22:49 +02:00
|
|
|
class ServerPort final : public WaitObject {
|
|
|
|
public:
|
|
|
|
/**
|
2016-05-22 19:30:13 +02:00
|
|
|
* Creates a pair of ServerPort and an associated ClientPort.
|
2016-05-22 18:22:49 +02:00
|
|
|
* @param max_sessions Maximum number of sessions to the port
|
|
|
|
* @param name Optional name of the ports
|
2016-12-05 17:02:08 +01:00
|
|
|
* @param hle_handler Optional HLE handler template for the port,
|
|
|
|
* ServerSessions crated from this port will inherit a reference to this handler.
|
2016-05-22 18:22:49 +02:00
|
|
|
* @return The created port tuple
|
|
|
|
*/
|
2016-09-19 03:01:46 +02:00
|
|
|
static std::tuple<SharedPtr<ServerPort>, SharedPtr<ClientPort>> CreatePortPair(
|
2016-12-05 17:02:08 +01:00
|
|
|
u32 max_sessions, std::string name = "UnknownPort",
|
|
|
|
std::shared_ptr<Service::SessionRequestHandler> hle_handler = nullptr);
|
2016-05-22 18:22:49 +02:00
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
std::string GetTypeName() const override {
|
|
|
|
return "ServerPort";
|
|
|
|
}
|
|
|
|
std::string GetName() const override {
|
|
|
|
return name;
|
|
|
|
}
|
2016-05-22 18:22:49 +02:00
|
|
|
|
|
|
|
static const HandleType HANDLE_TYPE = HandleType::ServerPort;
|
2016-09-18 02:38:01 +02:00
|
|
|
HandleType GetHandleType() const override {
|
|
|
|
return HANDLE_TYPE;
|
|
|
|
}
|
2016-05-22 18:22:49 +02:00
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
std::string name; ///< Name of port (optional)
|
2016-05-22 18:22:49 +02:00
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
std::vector<SharedPtr<WaitObject>>
|
|
|
|
pending_sessions; ///< ServerSessions waiting to be accepted by the port
|
2016-05-22 18:22:49 +02:00
|
|
|
|
2016-12-05 17:02:08 +01:00
|
|
|
/// This session's HLE request handler template (optional)
|
|
|
|
/// ServerSessions created from this port inherit a reference to this handler.
|
|
|
|
std::shared_ptr<Service::SessionRequestHandler> hle_handler;
|
|
|
|
|
2017-01-01 22:53:22 +01:00
|
|
|
bool ShouldWait(Thread* thread) const override;
|
|
|
|
void Acquire(Thread* thread) override;
|
2016-05-22 18:22:49 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
ServerPort();
|
|
|
|
~ServerPort() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|