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:
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(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  */
build_compdb.args
args
Definition: build_compdb.py:11
MythSystemLegacyIOHandler::Wait
void Wait(int fd)
Definition: mythsystemunix.cpp:225
hardwareprofile.smolt.timeout
float timeout
Definition: smolt.py:102
MythSystemLegacyIOHandler::m_pLock
QMutex m_pLock
Definition: mythsystemunix.h:53
MythSystemLegacyManager::m_pMap
MSMap_t m_pMap
Definition: mythsystemunix.h:74
MythSystemLegacyIOHandler::~MythSystemLegacyIOHandler
~MythSystemLegacyIOHandler()
Definition: mythsystemwindows.h:31
MythSystemLegacyManager
Definition: mythsystemunix.h:64
MythSystemLegacy
Definition: mythsystemlegacy.h:67
MythSystemLegacyManager::m_mapLock
QMutex m_mapLock
Definition: mythsystemunix.h:75
MythSystemLegacyPrivate
-*- Mode: c++ -*-
Definition: mythsystemprivate.h:21
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.
Definition: mythsystemunix.cpp:271
MThread::wait
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
Definition: mthread.cpp:300
discid.disc.read
def read(device=None, features=[])
Definition: disc.py:35
mythbaseexp.h
SystemTime
std::chrono::time_point< SystemClock > SystemTime
Definition: mythchrono.h:67
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:28
force
bool force
Definition: mythcommflag.cpp:70
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.
Definition: mythsystemunix.cpp:497
MythSystemLegacyPrivate::ParseShell
virtual bool ParseShell(const QString &cmd, QString &abscmd, QStringList &args)=0
mythsystemlegacy.h
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:29
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:30
MythSystemLegacyManager::jumpAbort
void jumpAbort(void)
Definition: mythsystemunix.cpp:490
MythSystemLegacyManager::m_jumpLock
QMutex m_jumpLock
Definition: mythsystemunix.h:77
MythSystemLegacyPrivate::Signal
virtual void Signal(int sig)=0
MythSystemLegacyManager::m_childCount
int m_childCount
Definition: mythsystemwindows.h:65
MythSystemLegacyIOHandler::MythSystemLegacyIOHandler
MythSystemLegacyIOHandler(bool read)
Definition: mythsystemunix.h:35
MythSystemLegacyManager::~MythSystemLegacyManager
~MythSystemLegacyManager() override
Definition: mythsystemunix.h:69
MythSystemLegacyIOHandler::HandleWrite
void HandleWrite(int fd, QBuffer *buff)
Definition: mythsystemunix.cpp:188
MythSystemLegacySignalManager
Definition: mythsystemunix.h:81
MythSystemLegacyIOHandler::m_read
bool m_read
Definition: mythsystemunix.h:58
MythSystemLegacyManager::append
void append(MythSystemLegacyUnix *ms)
Definition: mythsystemunix.cpp:448
MythSystemLegacyIOHandler::remove
void remove(int fd)
Definition: mythsystemunix.cpp:236
MythSystemLegacyIOHandler::m_pWait
QWaitCondition m_pWait
Definition: mythsystemunix.h:52
MythSystemLegacyPrivate::Fork
virtual void Fork(std::chrono::seconds timeout)=0
MythSystemLegacyWindows
Definition: mythsystemwindows.h:87
MythSystemLegacyIOHandler::wake
void wake()
Definition: mythsystemunix.cpp:251
MythSystemLegacyIOHandler::m_readbuf
std::array< char, 65536 > m_readbuf
Definition: mythsystemunix.h:59
MythSystemLegacyManager::m_jumpAbort
bool m_jumpAbort
Definition: mythsystemunix.h:76
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:48
mthread.h
MythSystemLegacyPrivate::JumpAbort
virtual void JumpAbort(void)=0
MythSystemLegacyIOHandler::insert
void insert(int fd, QBuffer *buff)
Definition: mythsystemunix.cpp:216
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.
Definition: mythsystemunix.cpp:88
MythSystemLegacyManager::ChildListRebuild
void ChildListRebuild()
Definition: mythsystemwindows.cpp:371
MythSystemLegacyIOHandler::m_pWaitLock
QMutex m_pWaitLock
Definition: mythsystemunix.h:51
MythSystemLegacyIOHandler::m_pMap
PMap_t m_pMap
Definition: mythsystemunix.h:54
MythSystemLegacyPrivate::Manage
virtual void Manage(void)=0
MythSystemLegacyIOHandler::HandleRead
void HandleRead(int fd, QBuffer *buff)
Definition: mythsystemunix.cpp:156