diff options
author | yuzubot <[email protected]> | 2024-03-04 13:02:54 +0000 |
---|---|---|
committer | yuzubot <[email protected]> | 2024-03-04 13:02:54 +0000 |
commit | 537296095ab24eddcb196b5ef98004f91de9c8c2 (patch) | |
tree | e75e9e2441dc3f8657cc42f2daaae08737949c2b /src/core/hle/service/am/event_observer.h | |
parent | 2ddac7b02b660bbc7bdfe4fef240699df6d52e64 (diff) | |
download | yuzu-mainline-master.tar.gz yuzu-mainline-master.zip |
Diffstat (limited to 'src/core/hle/service/am/event_observer.h')
-rw-r--r-- | src/core/hle/service/am/event_observer.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/core/hle/service/am/event_observer.h b/src/core/hle/service/am/event_observer.h new file mode 100644 index 000000000..3e52e8494 --- /dev/null +++ b/src/core/hle/service/am/event_observer.h @@ -0,0 +1,74 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/polyfill_thread.h" +#include "common/thread.h" +#include "core/hle/service/kernel_helpers.h" +#include "core/hle/service/os/event.h" +#include "core/hle/service/os/multi_wait.h" + +namespace Core { +class System; +} + +namespace Service::AM { + +struct Applet; +class ProcessHolder; +class WindowSystem; + +class EventObserver { +public: + explicit EventObserver(Core::System& system, WindowSystem& window_system); + ~EventObserver(); + + void TrackAppletProcess(Applet& applet); + void RequestUpdate(); + +private: + void LinkDeferred(); + MultiWaitHolder* WaitSignaled(); + void Process(MultiWaitHolder* holder); + bool WaitAndProcessImpl(); + void LoopProcess(); + +private: + void OnWakeupEvent(MultiWaitHolder* holder); + void OnProcessEvent(ProcessHolder* holder); + +private: + void DestroyAppletProcessHolderLocked(ProcessHolder* holder); + +private: + void ThreadFunc(); + +private: + // System reference and context. + Core::System& m_system; + KernelHelpers::ServiceContext m_context; + + // Window manager. + WindowSystem& m_window_system; + + // Guest event handle to wake up the event loop processor. + Event m_wakeup_event; + MultiWaitHolder m_wakeup_holder; + + // Mutex to protect remaining members. + std::mutex m_lock{}; + + // List of owned process holders. + Common::IntrusiveListBaseTraits<ProcessHolder>::ListType m_process_holder_list; + + // Multi-wait objects for new tasks. + MultiWait m_multi_wait; + MultiWait m_deferred_wait_list; + + // Processing thread. + std::thread m_thread{}; + std::stop_source m_stop_source{}; +}; + +} // namespace Service::AM |