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
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
|
|
|
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
|
|
|
|
* @return The created port tuple
|
|
|
|
*/
|
2016-09-19 03:01:46 +02:00
|
|
|
static std::tuple<SharedPtr<ServerPort>, SharedPtr<ClientPort>> CreatePortPair(
|
|
|
|
u32 max_sessions, std::string name = "UnknownPort");
|
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
|
|
|
|
|
|
|
bool ShouldWait() override;
|
|
|
|
void Acquire() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
ServerPort();
|
|
|
|
~ServerPort() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|