kernel/server_port: Return a std::pair from CreatePortPair()
Returns the same type that the function name describes.
This commit is contained in:
parent
11754778bb
commit
1afc2c72d6
|
@ -83,6 +83,8 @@ public:
|
|||
std::function<void()> prepare_reschedule_callback, u32 system_mode);
|
||||
~KernelSystem();
|
||||
|
||||
using PortPair = std::tuple<std::shared_ptr<ServerPort>, std::shared_ptr<ClientPort>>;
|
||||
|
||||
/**
|
||||
* Creates an address arbiter.
|
||||
*
|
||||
|
@ -150,8 +152,7 @@ public:
|
|||
* @param name Optional name of the ports
|
||||
* @return The created port tuple
|
||||
*/
|
||||
std::tuple<std::shared_ptr<ServerPort>, std::shared_ptr<ClientPort>> CreatePortPair(
|
||||
u32 max_sessions, std::string name = "UnknownPort");
|
||||
PortPair CreatePortPair(u32 max_sessions, std::string name = "UnknownPort");
|
||||
|
||||
/**
|
||||
* Creates a pair of ServerSession and an associated ClientSession.
|
||||
|
|
|
@ -35,9 +35,7 @@ void ServerPort::Acquire(Thread* thread) {
|
|||
ASSERT_MSG(!ShouldWait(thread), "object unavailable!");
|
||||
}
|
||||
|
||||
std::tuple<std::shared_ptr<ServerPort>, std::shared_ptr<ClientPort>> KernelSystem::CreatePortPair(
|
||||
u32 max_sessions, std::string name) {
|
||||
|
||||
KernelSystem::PortPair KernelSystem::CreatePortPair(u32 max_sessions, std::string name) {
|
||||
auto server_port{std::make_shared<ServerPort>(*this)};
|
||||
auto client_port{std::make_shared<ClientPort>(*this)};
|
||||
|
||||
|
@ -47,7 +45,7 @@ std::tuple<std::shared_ptr<ServerPort>, std::shared_ptr<ClientPort>> KernelSyste
|
|||
client_port->max_sessions = max_sessions;
|
||||
client_port->active_sessions = 0;
|
||||
|
||||
return std::make_tuple(std::move(server_port), std::move(client_port));
|
||||
return std::make_pair(std::move(server_port), std::move(client_port));
|
||||
}
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -1292,13 +1292,11 @@ ResultCode SVC::CreatePort(Handle* server_port, Handle* client_port, VAddr name_
|
|||
|
||||
std::shared_ptr<Process> current_process = kernel.GetCurrentProcess();
|
||||
|
||||
auto ports = kernel.CreatePortPair(max_sessions);
|
||||
CASCADE_RESULT(*client_port, current_process->handle_table.Create(
|
||||
std::move(std::get<std::shared_ptr<ClientPort>>(ports))));
|
||||
auto [server, client] = kernel.CreatePortPair(max_sessions);
|
||||
CASCADE_RESULT(*client_port, current_process->handle_table.Create(std::move(client)));
|
||||
// Note: The 3DS kernel also leaks the client port handle if the server port handle fails to be
|
||||
// created.
|
||||
CASCADE_RESULT(*server_port, current_process->handle_table.Create(
|
||||
std::move(std::get<std::shared_ptr<ServerPort>>(ports))));
|
||||
CASCADE_RESULT(*server_port, current_process->handle_table.Create(std::move(server)));
|
||||
|
||||
LOG_TRACE(Kernel_SVC, "called max_sessions={}", max_sessions);
|
||||
return RESULT_SUCCESS;
|
||||
|
|
Reference in New Issue