MythTV  master
mthread.h
Go to the documentation of this file.
1 #ifndef _MYTH_THREAD_H_
2 #define _MYTH_THREAD_H_
3 
4 #include <QThread>
5 
6 #include "mythbaseexp.h"
7 
8 class MThreadInternal;
9 class QStringList;
10 class QRunnable;
11 class MThread;
12 
16 bool MBASE_PUBLIC is_current_thread(QThread *thread);
19 
47 {
48  friend class MThreadInternal;
49  public:
51  explicit MThread(const QString &objectName);
56  explicit MThread(const QString &objectName, QRunnable *runnable);
57  virtual ~MThread();
58 
60  void RunProlog(void);
63  void RunEpilog(void);
64 
67  QThread *qthread(void);
68 
69  void setObjectName(const QString &name);
70  QString objectName(void) const;
71 
72  void setPriority(QThread::Priority priority);
73  QThread::Priority priority(void) const;
74 
75  bool isFinished(void) const;
76  bool isRunning(void) const;
77 
78  void setStackSize(uint stackSize);
79  uint stackSize(void) const;
80 
82  void exit(int retcode = 0);
84  void start(QThread::Priority = QThread::InheritPriority);
92  void terminate(void);
93  void quit(void);
94 
97  static void ThreadSetup(const QString&);
100  static void ThreadCleanup(void);
101 
102  public:
105  bool wait(unsigned long time = ULONG_MAX);
106 
110  static void Cleanup(void);
111  static void GetAllThreadNames(QStringList &list);
112  static void GetAllRunningThreadNames(QStringList &list);
113 
114  static const int kDefaultStartTimeout;
115  protected:
121  virtual void run(void);
123  int exec(void);
124 
125  static void setTerminationEnabled(bool enabled = true);
126  static void sleep(unsigned long time);
127  static void msleep(unsigned long time);
128  static void usleep(unsigned long time);
129 
131  QRunnable *m_runnable;
134 };
135 
136 #endif // _MYTH_THREAD_H_
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
MThreadInternal * m_thread
Definition: mthread.h:130
static const int kDefaultStartTimeout
Definition: mthread.h:114
unsigned int uint
Definition: compat.h:140
bool m_epilog_executed
Definition: mthread.h:133
bool MBASE_PUBLIC is_current_thread(MThread *thread)
Use this to determine if you are in the named thread.
Definition: mthread.cpp:41
int exec(void)
Definition: mthread.cpp:82
unsigned sleep(unsigned int x)
Definition: compat.h:152
QRunnable * m_runnable
Definition: mthread.h:131
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
static int run(MythMediaDevice *dev=nullptr, bool startRandomShow=false)
static bool isRunning(const char *program)
Returns true if a program containing the specified string is running on this machine.
bool m_prolog_executed
Definition: mthread.h:132
const char * name
Definition: ParseText.cpp:339