summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/server_manager.h
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2024-02-10 22:00:34 +0100
committerGitHub <noreply@github.com>2024-02-10 22:00:34 +0100
commit7c56ecca3f5fd2b70564209d765593c56a500c9e (patch)
treec1ebc60262c7103409b59f284bdd176e4c86c5d9 /src/core/hle/service/server_manager.h
parentFix multiplayer player count color in dark themes | Temp fix until #12744: Add green color for counts > 0 and < max_players - 1 (#12930) (diff)
parentglue: use multi wait API (diff)
downloadyuzu-7c56ecca3f5fd2b70564209d765593c56a500c9e.tar
yuzu-7c56ecca3f5fd2b70564209d765593c56a500c9e.tar.gz
yuzu-7c56ecca3f5fd2b70564209d765593c56a500c9e.tar.bz2
yuzu-7c56ecca3f5fd2b70564209d765593c56a500c9e.tar.lz
yuzu-7c56ecca3f5fd2b70564209d765593c56a500c9e.tar.xz
yuzu-7c56ecca3f5fd2b70564209d765593c56a500c9e.tar.zst
yuzu-7c56ecca3f5fd2b70564209d765593c56a500c9e.zip
Diffstat (limited to 'src/core/hle/service/server_manager.h')
-rw-r--r--src/core/hle/service/server_manager.h59
1 files changed, 33 insertions, 26 deletions
diff --git a/src/core/hle/service/server_manager.h b/src/core/hle/service/server_manager.h
index c4bc07262..5173ce46e 100644
--- a/src/core/hle/service/server_manager.h
+++ b/src/core/hle/service/server_manager.h
@@ -3,18 +3,17 @@
#pragma once
-#include <functional>
#include <list>
-#include <map>
#include <mutex>
-#include <string_view>
+#include <optional>
#include <vector>
#include "common/polyfill_thread.h"
#include "common/thread.h"
#include "core/hle/result.h"
#include "core/hle/service/hle_ipc.h"
-#include "core/hle/service/mutex.h"
+#include "core/hle/service/os/multi_wait.h"
+#include "core/hle/service/os/mutex.h"
namespace Core {
class System;
@@ -24,11 +23,13 @@ namespace Kernel {
class KEvent;
class KServerPort;
class KServerSession;
-class KSynchronizationObject;
} // namespace Kernel
namespace Service {
+class Port;
+class Session;
+
class ServerManager {
public:
explicit ServerManager(Core::System& system);
@@ -52,34 +53,40 @@ public:
static void RunServer(std::unique_ptr<ServerManager>&& server);
private:
- struct RequestState;
-
+ void LinkToDeferredList(MultiWaitHolder* holder);
+ void LinkDeferred();
+ MultiWaitHolder* WaitSignaled();
+ Result Process(MultiWaitHolder* holder);
+ bool WaitAndProcessImpl();
Result LoopProcessImpl();
- Result WaitAndProcessImpl();
- Result OnPortEvent(Kernel::KServerPort* port, SessionRequestHandlerFactory&& handler_factory);
- Result OnSessionEvent(Kernel::KServerSession* session,
- std::shared_ptr<SessionRequestManager>&& manager);
- Result OnDeferralEvent(std::list<RequestState>&& deferrals);
- Result CompleteSyncRequest(RequestState&& state);
+
+ Result OnPortEvent(Port* port);
+ Result OnSessionEvent(Session* session);
+ Result OnDeferralEvent();
+ Result CompleteSyncRequest(Session* session);
+
+private:
+ void DestroySession(Session* session);
private:
Core::System& m_system;
- Mutex m_serve_mutex;
- std::mutex m_list_mutex;
+ Mutex m_selection_mutex;
- // Guest state tracking
- std::map<Kernel::KServerPort*, SessionRequestHandlerFactory> m_ports{};
- std::map<Kernel::KServerSession*, std::shared_ptr<SessionRequestManager>> m_sessions{};
- Kernel::KEvent* m_event{};
+ // Events
+ Kernel::KEvent* m_wakeup_event{};
Kernel::KEvent* m_deferral_event{};
- // Deferral tracking
- struct RequestState {
- Kernel::KServerSession* session;
- std::shared_ptr<HLERequestContext> context;
- std::shared_ptr<SessionRequestManager> manager;
- };
- std::list<RequestState> m_deferrals{};
+ // Deferred wait list
+ std::mutex m_deferred_list_mutex{};
+ MultiWait m_deferred_list{};
+
+ // Guest state tracking
+ MultiWait m_multi_wait{};
+ Common::IntrusiveListBaseTraits<Port>::ListType m_servers{};
+ Common::IntrusiveListBaseTraits<Session>::ListType m_sessions{};
+ std::list<Session*> m_deferred_sessions{};
+ std::optional<MultiWaitHolder> m_wakeup_holder{};
+ std::optional<MultiWaitHolder> m_deferral_holder{};
// Host state tracking
Common::Event m_stopped{};