summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/session.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/session.h')
-rw-r--r--src/core/hle/kernel/session.h57
1 files changed, 47 insertions, 10 deletions
diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h
index 94395f9f5..5a9d4e9ad 100644
--- a/src/core/hle/kernel/session.h
+++ b/src/core/hle/kernel/session.h
@@ -1,27 +1,64 @@
1// Copyright 2018 yuzu emulator team 1// Copyright 2019 yuzu emulator team
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
7#include "core/hle/kernel/object.h" 7#include <memory>
8#include <string>
9
10#include "core/hle/kernel/wait_object.h"
11#include "core/hle/result.h"
8 12
9namespace Kernel { 13namespace Kernel {
10 14
11class ClientSession; 15class ClientSession;
12class ClientPort;
13class ServerSession; 16class ServerSession;
14 17
15/** 18/**
16 * Parent structure to link the client and server endpoints of a session with their associated 19 * Parent structure to link the client and server endpoints of a session with their associated
17 * client port. The client port need not exist, as is the case for portless sessions like the 20 * client port.
18 * FS File and Directory sessions. When one of the endpoints of a session is destroyed, its
19 * corresponding field in this structure will be set to nullptr.
20 */ 21 */
21class Session final { 22class Session final : public WaitObject {
22public: 23public:
23 std::weak_ptr<ClientSession> client; ///< The client endpoint of the session. 24 explicit Session(KernelCore& kernel);
24 std::weak_ptr<ServerSession> server; ///< The server endpoint of the session. 25 ~Session() override;
25 std::shared_ptr<ClientPort> port; ///< The port that this session is associated with (optional). 26
27 using SessionPair = std::pair<std::shared_ptr<ClientSession>, std::shared_ptr<ServerSession>>;
28
29 static SessionPair Create(KernelCore& kernel, std::string name = "Unknown");
30
31 std::string GetName() const override {
32 return name;
33 }
34
35 static constexpr HandleType HANDLE_TYPE = HandleType::Session;
36 HandleType GetHandleType() const override {
37 return HANDLE_TYPE;
38 }
39
40 bool ShouldWait(const Thread* thread) const override;
41
42 void Acquire(Thread* thread) override;
43
44 std::shared_ptr<ClientSession> Client() {
45 if (auto result{client.lock()}) {
46 return result;
47 }
48 return {};
49 }
50
51 std::shared_ptr<ServerSession> Server() {
52 if (auto result{server.lock()}) {
53 return result;
54 }
55 return {};
56 }
57
58private:
59 std::string name;
60 std::weak_ptr<ClientSession> client;
61 std::weak_ptr<ServerSession> server;
26}; 62};
63
27} // namespace Kernel 64} // namespace Kernel