2019-11-25 18:28:48 -05:00
|
|
|
// Copyright 2019 yuzu emulator team
|
2015-01-31 19:56:59 -05:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2019-11-25 18:28:48 -05:00
|
|
|
#include "common/assert.h"
|
|
|
|
#include "core/hle/kernel/client_session.h"
|
2021-02-12 19:05:24 -05:00
|
|
|
#include "core/hle/kernel/k_scoped_resource_reservation.h"
|
2019-11-25 18:28:48 -05:00
|
|
|
#include "core/hle/kernel/server_session.h"
|
2015-01-31 19:56:59 -05:00
|
|
|
#include "core/hle/kernel/session.h"
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2020-12-22 01:36:53 -05:00
|
|
|
Session::Session(KernelCore& kernel) : KSynchronizationObject{kernel} {}
|
2021-02-12 19:05:24 -05:00
|
|
|
Session::~Session() {
|
|
|
|
// Release reserved resource when the Session pair was created.
|
|
|
|
kernel.GetSystemResourceLimit()->Release(LimitableResource::Sessions, 1);
|
|
|
|
}
|
2019-11-25 18:28:48 -05:00
|
|
|
|
|
|
|
Session::SessionPair Session::Create(KernelCore& kernel, std::string name) {
|
2021-02-12 19:05:24 -05:00
|
|
|
// Reserve a new session from the resource limit.
|
|
|
|
KScopedResourceReservation session_reservation(kernel.GetSystemResourceLimit(),
|
|
|
|
LimitableResource::Sessions);
|
|
|
|
ASSERT(session_reservation.Succeeded());
|
2019-11-25 18:28:48 -05:00
|
|
|
auto session{std::make_shared<Session>(kernel)};
|
|
|
|
auto client_session{Kernel::ClientSession::Create(kernel, session, name + "_Client").Unwrap()};
|
|
|
|
auto server_session{Kernel::ServerSession::Create(kernel, session, name + "_Server").Unwrap()};
|
|
|
|
|
|
|
|
session->name = std::move(name);
|
|
|
|
session->client = client_session;
|
|
|
|
session->server = server_session;
|
|
|
|
|
2021-02-12 19:05:24 -05:00
|
|
|
session_reservation.Commit();
|
2019-11-25 18:28:48 -05:00
|
|
|
return std::make_pair(std::move(client_session), std::move(server_session));
|
|
|
|
}
|
|
|
|
|
2020-02-11 16:36:39 -05:00
|
|
|
bool Session::IsSignaled() const {
|
|
|
|
UNIMPLEMENTED();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-01-20 02:48:02 -05:00
|
|
|
} // namespace Kernel
|