/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/Foundation/Communication/Implementation/MessageLoop.h
69 строк
2 KB
Ingrater
clang-tidy use modernize-use-equals-default check (#951)
21 май 2023, 11:31
Не верифицирован
21 май 2023, 11:31
345d6ff
Код
Авторство
О чём код?
#pragma once #include <Foundation/Basics.h> #include <Foundation/Configuration/Singleton.h> #include <Foundation/Configuration/Startup.h> #include <Foundation/Containers/Deque.h> #include <Foundation/Threading/Mutex.h> #include <Foundation/Threading/Thread.h> class ezProcessMessage; class ezIpcChannel; class ezLoopThread; /// \brief Internal sub-system used by ezIpcChannel. /// /// This sub-system creates a background thread as soon as the first ezIpcChannel /// is added to it. This class should never be needed to be accessed outside /// of ezIpcChannel implementations. class EZ_FOUNDATION_DLL ezMessageLoop { EZ_DECLARE_SINGLETON(ezMessageLoop); public: ezMessageLoop(); virtual ~ezMessageLoop() = default; ; /// \brief Needs to be called by newly created channels' constructors. void AddChannel(ezIpcChannel* pChannel); void RemoveChannel(ezIpcChannel* pChannel); protected: EZ_MAKE_SUBSYSTEM_STARTUP_FRIEND(Foundation, MessageLoop); friend class ezLoopThread; friend class ezIpcChannel; void StartUpdateThread(); void StopUpdateThread(); void RunLoop(); bool ProcessTasks(); void Quit(); /// \brief Wake up the message loop when new work comes in. virtual void WakeUp() = 0; /// \brief Waits until a new message has been processed (sent, received). /// \param timeout If negative, wait indefinitely. /// \param pFilter If not null, wait for a message for the specific channel. /// \return Returns whether a message was received or the timeout was reached. virtual bool WaitForMessages(ezInt32 iTimeout, ezIpcChannel* pFilter) = 0; ezThreadID m_ThreadId = 0; mutable ezMutex m_Mutex; bool m_bShouldQuit = false; bool m_bCallTickFunction = false; class ezLoopThread* m_pUpdateThread = nullptr; ezMutex m_TasksMutex; ezDynamicArray<ezIpcChannel*> m_ConnectQueue; ezDynamicArray<ezIpcChannel*> m_DisconnectQueue; ezDynamicArray<ezIpcChannel*> m_SendQueue; // Thread local copies of the different queues for the ProcessTasks method ezDynamicArray<ezIpcChannel*> m_ConnectQueueTask; ezDynamicArray<ezIpcChannel*> m_DisconnectQueueTask; ezDynamicArray<ezIpcChannel*> m_SendQueueTask; ezDynamicArray<ezIpcChannel*> m_AllAddedChannels; };