2019-11-26 00:28:48 +01:00
|
|
|
// Copyright 2019 yuzu emulator team
|
2017-01-05 05:23:17 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-11-26 00:28:48 +01:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
2019-12-08 04:09:20 +01:00
|
|
|
#include <utility>
|
2019-11-26 00:28:48 +01:00
|
|
|
|
2020-02-11 15:46:25 +01:00
|
|
|
#include "core/hle/kernel/synchronization_object.h"
|
2017-01-05 05:23:17 +01:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class ClientSession;
|
|
|
|
class ServerSession;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parent structure to link the client and server endpoints of a session with their associated
|
2019-11-26 00:28:48 +01:00
|
|
|
* client port.
|
2017-01-05 05:23:17 +01:00
|
|
|
*/
|
2020-02-11 15:46:25 +01:00
|
|
|
class Session final : public SynchronizationObject {
|
2017-01-05 05:23:17 +01:00
|
|
|
public:
|
2019-11-26 00:28:48 +01: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;
|
|
|
|
|
2020-02-11 22:36:39 +01:00
|
|
|
bool IsSignaled() const override;
|
|
|
|
|
2019-11-26 00:28:48 +01:00
|
|
|
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-05 05:23:17 +01:00
|
|
|
};
|
2019-11-26 00:28:48 +01:00
|
|
|
|
2018-01-20 08:48:02 +01:00
|
|
|
} // namespace Kernel
|