MythTV master
mythsystemwindows.h
Go to the documentation of this file.
1
2
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
23using MSMap_t = QMap<HANDLE, MythSystemLegacyWindows *>;
24using PMap_t = QMap<HANDLE, QBuffer *>;
25using MSList_t = QList<MythSystemLegacyWindows *>;
26
28{
29 public:
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;
47
48 bool m_read;
49 char m_readbuf[65536];
50};
51
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:
94
95 void Fork(std::chrono::seconds 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 SystemTime m_timeout {0s};
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 */
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
Definition: mthread.cpp:300
void HandleWrite(int fd, QBuffer *buff)
MythSystemLegacyIOHandler(bool read)
void insert(int fd, QBuffer *buff)
void HandleRead(int fd, QBuffer *buff)
std::array< char, 65536 > m_readbuf
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
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 *ms)
virtual void Fork(std::chrono::seconds timeout)=0
virtual void Signal(int sig)=0
virtual void Term(bool force=false)=0
virtual bool ParseShell(const QString &cmd, QString &abscmd, QStringList &args)=0
virtual void JumpAbort(void)=0
virtual void Manage(void)=0
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
~MythSystemLegacyWindows()=default
#define MBASE_PUBLIC
Definition: mythbaseexp.h:8
std::chrono::time_point< SystemClock > SystemTime
Definition: mythchrono.h:67
QList< QPointer< MythSystemLegacyUnix > > MSList_t
QMap< int, QBuffer * > PMap_t
QMap< pid_t, QPointer< MythSystemLegacyUnix > > MSMap_t
def read(device=None, features=[])
Definition: disc.py:35