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 using MSMap_t = QMap<HANDLE, MythSystemLegacyWindows *>;
24 using PMap_t = QMap<HANDLE, QBuffer *>;
25 using 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;
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);
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  */
force
bool force
Definition: mythtv/programs/mythcommflag/main.cpp:74
build_compdb.args
args
Definition: build_compdb.py:11
MythSystemLegacyIOHandler::Wait
void Wait(int fd)
Definition: mythsystemunix.cpp:216
hardwareprofile.smolt.timeout
float timeout
Definition: smolt.py:103
MythSystemLegacyIOHandler::m_pLock
QMutex m_pLock
Definition: mythsystemunix.h:52
MythSystemLegacyManager::m_pMap
MSMap_t m_pMap
Definition: mythsystemunix.h:73
MythSystemLegacyIOHandler::~MythSystemLegacyIOHandler
~MythSystemLegacyIOHandler()
Definition: mythsystemwindows.h:31
MythSystemLegacyManager
Definition: mythsystemunix.h:64
MythSystemLegacy
Definition: mythsystemlegacy.h:68
MythSystemLegacyManager::m_mapLock
QMutex m_mapLock
Definition: mythsystemunix.h:74
MythSystemLegacyPrivate
Definition: mythsystemprivate.h:26
MythSystemLegacyManager::run
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
discid.disc.read
def read(device=None, features=[])
Definition: disc.py:35
mythbaseexp.h
MythSystemLegacyPrivate::Term
virtual void Term(bool force=false)=0
mythsystemprivate.h
MythSystemLegacySignalManager::~MythSystemLegacySignalManager
~MythSystemLegacySignalManager()
Definition: mythsystemwindows.h:81
MythSystemLegacySignalManager::MythSystemLegacySignalManager
MythSystemLegacySignalManager()
Definition: mythsystemwindows.h:79
MSMap_t
QMap< pid_t, QPointer< MythSystemLegacyUnix > > MSMap_t
Definition: mythsystemunix.h:27
MythSystemLegacySignalManager::run
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
MythSystemLegacyPrivate::ParseShell
virtual bool ParseShell(const QString &cmd, QString &abscmd, QStringList &args)=0
mythsystemlegacy.h
MythSystemLegacyManager::~MythSystemLegacyManager
~MythSystemLegacyManager()
MythSystemLegacyManager::MythSystemLegacyManager
MythSystemLegacyManager()
Definition: mythsystemwindows.h:55
MBASE_PUBLIC
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
PMap_t
QMap< int, QBuffer * > PMap_t
Definition: mythsystemunix.h:28
MythSystemLegacyWindows::~MythSystemLegacyWindows
~MythSystemLegacyWindows()=default
MythSystemLegacyManager::m_children
HANDLE * m_children
Definition: mythsystemwindows.h:66
MythSystemLegacyIOHandler
Definition: mythsystemunix.h:32
MSList_t
QList< QPointer< MythSystemLegacyUnix > > MSList_t
Definition: mythsystemunix.h:29
MythSystemLegacyManager::jumpAbort
void jumpAbort(void)
MythSystemLegacyManager::m_jumpLock
QMutex m_jumpLock
Definition: mythsystemunix.h:76
MythSystemLegacyPrivate::Fork
virtual void Fork(time_t timeout)=0
MythSystemLegacyPrivate::Signal
virtual void Signal(int sig)=0
MythSystemLegacyManager::m_childCount
int m_childCount
Definition: mythsystemwindows.h:65
MythSystemLegacyIOHandler::MythSystemLegacyIOHandler
MythSystemLegacyIOHandler(bool read)
MythSystemLegacyIOHandler::HandleWrite
void HandleWrite(int fd, QBuffer *buff)
Definition: mythsystemunix.cpp:179
MythSystemLegacySignalManager
Definition: mythsystemunix.h:81
MythSystemLegacyIOHandler::m_read
bool m_read
Definition: mythsystemunix.h:57
MythSystemLegacyManager::append
void append(MythSystemLegacyUnix *ms)
Definition: mythsystemunix.cpp:439
MythSystemLegacyIOHandler::remove
void remove(int fd)
Definition: mythsystemunix.cpp:227
MythSystemLegacyIOHandler::m_pWait
QWaitCondition m_pWait
Definition: mythsystemunix.h:51
MythSystemLegacyWindows
Definition: mythsystemwindows.h:88
MythSystemLegacyIOHandler::wake
void wake()
MythSystemLegacyIOHandler::m_readbuf
std::array< char, 65536 > m_readbuf
Definition: mythsystemunix.h:58
MythSystemLegacyManager::m_jumpAbort
bool m_jumpAbort
Definition: mythsystemunix.h:75
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
mthread.h
MythSystemLegacyPrivate::JumpAbort
virtual void JumpAbort(void)=0
MythSystemLegacyIOHandler::insert
void insert(int fd, QBuffer *buff)
Definition: mythsystemunix.cpp:207
MThread::wait
bool wait(unsigned long time=ULONG_MAX)
Wait for the MThread to exit, with a maximum timeout.
Definition: mthread.cpp:305
MythSystemLegacyIOHandler::run
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
MythSystemLegacyManager::ChildListRebuild
void ChildListRebuild()
Definition: mythsystemwindows.cpp:371
MythSystemLegacyIOHandler::m_pWaitLock
QMutex m_pWaitLock
Definition: mythsystemunix.h:50
MythSystemLegacyIOHandler::m_pMap
PMap_t m_pMap
Definition: mythsystemunix.h:53
MythSystemLegacyPrivate::Manage
virtual void Manage(void)=0
MythSystemLegacyIOHandler::HandleRead
void HandleRead(int fd, QBuffer *buff)
Definition: mythsystemunix.cpp:147