summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/session.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-11-26 00:28:48 +0100
committerbunnei <bunneidev@gmail.com>2019-11-28 18:01:53 +0100
commitc3d3b173d39b7c12fa9b3d5d34040e9377f2888e (patch)
tree61ff05239fe2b3d08bcf775f1528263cffc9aff4 /src/core/hle/kernel/session.h
parentMerge pull request #3169 from lioncash/memory (diff)
downloadyuzu-c3d3b173d39b7c12fa9b3d5d34040e9377f2888e.tar
yuzu-c3d3b173d39b7c12fa9b3d5d34040e9377f2888e.tar.gz
yuzu-c3d3b173d39b7c12fa9b3d5d34040e9377f2888e.tar.bz2
yuzu-c3d3b173d39b7c12fa9b3d5d34040e9377f2888e.tar.lz
yuzu-c3d3b173d39b7c12fa9b3d5d34040e9377f2888e.tar.xz
yuzu-c3d3b173d39b7c12fa9b3d5d34040e9377f2888e.tar.zst
yuzu-c3d3b173d39b7c12fa9b3d5d34040e9377f2888e.zip
Diffstat (limited to '')
-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 @@
-// Copyright 2018 yuzu emulator team
+// Copyright 2019 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
-#include "core/hle/kernel/object.h"
+#include <memory>
+#include <string>
+
+#include "core/hle/kernel/wait_object.h"
+#include "core/hle/result.h"
namespace Kernel {
class ClientSession;
-class ClientPort;
class ServerSession;
/**
* Parent structure to link the client and server endpoints of a session with their associated
- * client port. The client port need not exist, as is the case for portless sessions like the
- * FS File and Directory sessions. When one of the endpoints of a session is destroyed, its
- * corresponding field in this structure will be set to nullptr.
+ * client port.
*/
-class Session final {
+class Session final : public WaitObject {
public:
- std::weak_ptr<ClientSession> client; ///< The client endpoint of the session.
- std::weak_ptr<ServerSession> server; ///< The server endpoint of the session.
- std::shared_ptr<ClientPort> port; ///< The port that this session is associated with (optional).
+ 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;
};
+
} // namespace Kernel