Plasma Engine  2.0
Loading...
Searching...
No Matches
MessageLoop_Linux.h
1
2#pragma once
3
4#include <Foundation/FoundationInternal.h>
5PL_FOUNDATION_INTERNAL_HEADER
6
7#if PL_ENABLED(PL_PLATFORM_LINUX)
8
9# include <Foundation/Basics.h>
10# include <Foundation/Communication/Implementation/MessageLoop.h>
11# include <Foundation/Threading/Mutex.h>
12
13# include <poll.h>
14
15class plIpcChannel;
16class plPipeChannel_linux;
17
18# ifndef _PL_DEFINED_POLLFD_POD
19# define _PL_DEFINED_POLLFD_POD
20PL_DEFINE_AS_POD_TYPE(struct pollfd);
21# endif
22
23class PL_FOUNDATION_DLL plMessageLoop_linux : public plMessageLoop
24{
25public:
26 plMessageLoop_linux();
27 ~plMessageLoop_linux();
28
29protected:
30 virtual void WakeUp() override;
31 virtual bool WaitForMessages(plInt32 iTimeout, plIpcChannel* pFilter) override;
32
33private:
34 friend class plPipeChannel_linux;
35
36 enum class WaitType
37 {
38 Accept,
39 IncomingMessage,
40 Connect,
41 Send
42 };
43
44 void RegisterWait(plPipeChannel_linux* pChannel, WaitType type, int fd);
45 void RemovePendingWaits(plPipeChannel_linux* pChannel);
46
47private:
48 struct WaitInfo
49 {
50 PL_DECLARE_POD_TYPE();
51
52 plPipeChannel_linux* m_pChannel;
53 WaitType m_type;
54 };
55
56 // m_waitInfos and m_pollInfos are alway the same size.
57 // related information is stored at the same index.
60 plMutex m_pollMutex;
61 plAtomicInteger32 m_numPendingPollModifications = 0;
62 int m_wakeupPipeReadEndFd = -1;
63 int m_wakeupPipeWriteEndFd = -1;
64};
65
66#endif
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Base class for a communication channel between processes.
Definition IpcChannel.h:44
Internal sub-system used by plIpcChannel.
Definition MessageLoop.h:20
virtual bool WaitForMessages(plInt32 iTimeout, plIpcChannel *pFilter)=0
Waits until a new message has been processed (sent, received).
virtual void WakeUp()=0
Wake up the message loop when new work comes in.
Provides a simple mechanism for mutual exclusion to prevent multiple threads from accessing a shared ...
Definition Mutex.h:13