kwave  18.07.70
WorkerThread.h
Go to the documentation of this file.
1 /***************************************************************************
2  libkwave/WorkerThread.h - worker thread for Kwave
3  -------------------
4  begin : Sun Apr 06 2008
5  copyright : (C) 2008 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef WORKER_THREAD_H
19 #define WORKER_THREAD_H
20 
21 #include "config.h"
22 #include <pthread.h>
23 
24 #include <QAtomicInt>
25 #include <QtGlobal>
26 #include <QMutex>
27 #include <QObject>
28 #include <QThread>
29 #include <QVariant>
30 
31 namespace Kwave
32 {
33  class Runnable;
34 
35  class Q_DECL_EXPORT WorkerThread: public QThread
36  {
37  Q_OBJECT
38  public:
39 
41  explicit WorkerThread(Kwave::Runnable *runnable, QVariant params);
42 
44  virtual ~WorkerThread() Q_DECL_OVERRIDE;
45 
47  virtual void start();
48 
56  virtual int stop(unsigned int timeout = 10000);
57 
62  virtual void run() Q_DECL_OVERRIDE;
63 
68  virtual void cancel();
69 
75  bool shouldStop();
76 
77  private:
78 
81 
83  QVariant m_params;
84 
86  QMutex m_lock;
87 
89  QMutex m_lock_sighup;
90 
92  QAtomicInt m_should_stop;
93 
99  pthread_t m_tid;
100 
102  pthread_t m_owner_tid;
103 
104  };
105 
106 }
107 
108 #endif /* WORKER_THREAD_H */
109 
110 //***************************************************************************
111 //***************************************************************************
Definition: App.h:33
QAtomicInt m_should_stop
Definition: WorkerThread.h:92
Kwave::Runnable * m_runnable
Definition: WorkerThread.h:80