2019-11-25 15:28:48 -08:00
|
|
|
// Copyright 2019 yuzu emulator team
|
2017-01-04 20:23:17 -08:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-11-25 15:28:48 -08:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "core/hle/kernel/wait_object.h"
|
|
|
|
#include "core/hle/result.h"
|
2017-01-04 20:23:17 -08:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class ClientSession;
|
|
|
|
class ServerSession;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parent structure to link the client and server endpoints of a session with their associated
|
2019-11-25 15:28:48 -08:00
|
|
|
* client port.
|
2017-01-04 20:23:17 -08:00
|
|
|
*/
|
2019-11-25 15:28:48 -08:00
|
|
|
class Session final : public WaitObject {
|
2017-01-04 20:23:17 -08:00
|
|
|
public:
|
2019-11-25 15:28:48 -08:00
|
|
|
explicit Session(KernelCore& kernel);
|
|
|
|
~Session() override;
|
|
|
|
|
|
|
|
using SessionPair = std::pair<std::shared_ptr<ClientSession>, std::shared_ptr<ServerSession>>;
|
|
|
|
|
|
|
|
static SessionPair Create(KernelCore& kernel, std::string name = "Unknown");
|
|
|
|
|
|
|
|
std::string GetName() const override {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr HandleType HANDLE_TYPE = HandleType::Session;
|
|
|
|
HandleType GetHandleType() const override {
|
|
|
|
return HANDLE_TYPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ShouldWait(const Thread* thread) const override;
|
|
|
|
|
|
|
|
void Acquire(Thread* thread) override;
|
|
|
|
|
|
|
|
std::shared_ptr<ClientSession> Client() {
|
|
|
|
if (auto result{client.lock()}) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<ServerSession> Server() {
|
|
|
|
if (auto result{server.lock()}) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string name;
|
|
|
|
std::weak_ptr<ClientSession> client;
|
|
|
|
std::weak_ptr<ServerSession> server;
|
2017-01-04 20:23:17 -08:00
|
|
|
};
|
2019-11-25 15:28:48 -08:00
|
|
|
|
2018-01-19 23:48:02 -08:00
|
|
|
} // namespace Kernel
|