2020-12-28 10:15:37 -05:00
|
|
|
// Copyright 2019 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
|
2020-12-31 05:02:49 -05:00
|
|
|
#include "core/hle/kernel/synchronization_object.h"
|
2020-12-28 10:15:37 -05:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class ClientSession;
|
|
|
|
class ServerSession;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parent structure to link the client and server endpoints of a session with their associated
|
|
|
|
* client port.
|
|
|
|
*/
|
2020-12-31 05:02:49 -05:00
|
|
|
class Session final : public SynchronizationObject {
|
2020-12-28 10:15:37 -05:00
|
|
|
public:
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-12-31 05:02:49 -05:00
|
|
|
bool ShouldWait(const Thread* thread) const override;
|
|
|
|
|
2020-12-28 10:15:37 -05:00
|
|
|
bool IsSignaled() const override;
|
|
|
|
|
2020-12-31 05:02:49 -05:00
|
|
|
void Acquire(Thread* thread) override;
|
|
|
|
|
2020-12-28 10:15:37 -05:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Kernel
|