MythTV  master
mythsystemwindows.h
Go to the documentation of this file.
1 
3 #ifndef _MYTHSYSTEM_WINDOWS_H_
4 #define _MYTHSYSTEM_WINDOWS_H_
5 
6 #include <Windows.h>
7 #include <csignal>
8 
9 #include <QWaitCondition>
10 #include <QBuffer>
11 #include <QObject>
12 #include <QMutex>
13 #include <QList>
14 #include <QMap>
15 
16 #include "mythsystemprivate.h"
17 #include "mythbaseexp.h"
18 #include "mythsystemlegacy.h"
19 #include "mthread.h"
20 
22 
23 typedef QMap<HANDLE, MythSystemLegacyWindows *> MSMap_t;
24 typedef QMap<HANDLE, QBuffer *> PMap_t;
25 typedef QList<MythSystemLegacyWindows *> MSList_t;
26 
28 {
29  public:
30  explicit MythSystemLegacyIOHandler(bool read);
32  void run(void) override; // MThread
33 
34  void insert(HANDLE h, QBuffer *buff);
35  void Wait(HANDLE h);
36  void remove(HANDLE h);
37  void wake();
38 
39  private:
40  bool HandleRead(HANDLE h, QBuffer *buff);
41  bool HandleWrite(HANDLE h, QBuffer *buff);
42 
43  QMutex m_pWaitLock;
44  QWaitCondition m_pWait;
45  QMutex m_pLock;
46  PMap_t m_pMap;
47 
48  bool m_read;
49  char m_readbuf[65536];
50 };
51 
52 class MythSystemLegacyManager : public MThread
53 {
54  public:
56  : MThread("SystemManager") {}
58  void run(void) override; // MThread
60  void jumpAbort(void);
61 
62  private:
63  void ChildListRebuild();
64 
65  int m_childCount {0};
66  HANDLE *m_children {nullptr};
68  QMutex m_mapLock;
69 
70  bool m_jumpAbort {false};
71  QMutex m_jumpLock;
72 };
73 
74 // spawn separate thread for signals to prevent manager
75 // thread from blocking in some slot
77 {
78  public:
80  : MThread("SystemSignalManager") {}
82  void run(void) override; // MThread
83  private:
84 };
85 
86 
88 {
89  Q_OBJECT
90 
91  public:
92  explicit MythSystemLegacyWindows(MythSystemLegacy *parent);
93  ~MythSystemLegacyWindows() = default;
94 
95  void Fork(time_t timeout) override; // MythSystemLegacyPrivate
96  void Manage(void) override; // MythSystemLegacyPrivate
97 
98  void Term(bool force=false) override; // MythSystemLegacyPrivate
99  void Signal(int sig) override; // MythSystemLegacyPrivate
100  void JumpAbort(void) override; // MythSystemLegacyPrivate
101 
102  bool ParseShell(const QString &cmd, QString &abscmd,
103  QStringList &args) override; // MythSystemLegacyPrivate
104 
108 
109  private:
110  HANDLE m_child {nullptr};
111  time_t m_timeout {0};
112 
113  HANDLE m_stdpipe[3];
114 };
115 
116 #endif // _MYTHSYSTEM_WINDOWS_H_
117 
118 /*
119  * vim:ts=4:sw=4:ai:et:si:sts=4
120  */
virtual void Term(bool force=false)=0
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
virtual void Manage(void)=0
QMap< HANDLE, MythSystemLegacyWindows * > MSMap_t
bool wait(unsigned long time=ULONG_MAX)
Wait for the MThread to exit, with a maximum timeout.
Definition: mthread.cpp:311
void HandleRead(int fd, QBuffer *buff)
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
def read(device=None, features=[])
Definition: disc.py:35
void insert(int fd, QBuffer *buff)
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
void HandleWrite(int fd, QBuffer *buff)
QMap< HANDLE, QBuffer * > PMap_t
virtual bool ParseShell(const QString &cmd, QString &abscmd, QStringList &args)=0
QList< MythSystemLegacyWindows * > MSList_t
QMap< int, QBuffer * > PMap_t
virtual void JumpAbort(void)=0
virtual void Fork(time_t timeout)=0
QMap< pid_t, QPointer< MythSystemLegacyUnix > > MSMap_t
virtual void Signal(int sig)=0
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
void append(MythSystemLegacyUnix *)