2019-11-25 18:28:48 -05:00
|
|
|
// Copyright 2019 yuzu emulator team
|
2017-01-04 23:23:17 -05:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-11-25 18:28:48 -05:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
2019-12-07 22:09:20 -05:00
|
|
|
#include <utility>
|
2019-11-25 18:28:48 -05:00
|
|
|
|
2020-02-11 09:46:25 -05:00
|
|
|
#include "core/hle/kernel/synchronization_object.h"
|
2017-01-04 23:23:17 -05: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 18:28:48 -05:00
|
|
|
* client port.
|
2017-01-04 23:23:17 -05:00
|
|
|
*/
|
2020-02-11 09:46:25 -05:00
|
|
|
class Session final : public SynchronizationObject {
|
2017-01-04 23:23:17 -05:00
|
|
|
public:
|
2019-11-25 18:28:48 -05: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 16:36:39 -05:00
|
|
|
bool IsSignaled() const override;
|
|
|
|
|
2019-11-25 18:28:48 -05: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-04 23:23:17 -05:00
|
|
|
};
|
2019-11-25 18:28:48 -05:00
|
|
|
|
2018-01-20 02:48:02 -05:00
|
|
|
} // namespace Kernel
|