23 #include <QApplication> 26 #undef DEBUG_FIND_DEADLOCKS 27 #ifdef DEBUG_FIND_DEADLOCKS 36 #define MAX_ATTEMPTS_TO_STOP 8 47 printf(
"\r\n--- SIGHUP ---\r\n");
55 m_lock(), m_lock_sighup(),
57 m_tid(pthread_self()),
58 m_owner_tid(pthread_self())
61 Q_ASSERT(this->thread() == QThread::currentThread());
62 Q_ASSERT(this->thread() == qApp->thread());
80 qDebug(
"WorkerThread::~WorkerThread(): waiting for normal shutdown");
82 qDebug(
"WorkerThread::~WorkerThread(): stopping");
85 Q_ASSERT(!isRunning());
91 QMutexLocker lock(&
m_lock);
102 QMutexLocker lock(&
m_lock);
103 if (!isRunning())
return 0;
105 if (timeout < 1000) timeout = 1000;
114 pthread_kill(
m_tid, SIGHUP);
115 if (!isRunning())
return 0;
119 if (!isRunning())
return 0;
121 if (!isRunning())
return 0;
124 qWarning(
"WorkerThread::stop(): sending SIGHUP");
128 if (!isRunning())
return 0;
130 pthread_kill(
m_tid, SIGHUP);
132 if (!isRunning())
return 0;
134 if (!isRunning())
return 0;
137 #ifdef DEBUG_FIND_DEADLOCKS 139 qDebug(
"WorkerThread::stop(): pthread_self()=%08X",
140 (
unsigned int)pthread_self());
142 size_t n = backtrace(buf, 256);
143 backtrace_symbols_fd(buf, n, 2);
147 qDebug(
"WorkerThread::stop(): canceling thread");
162 m_tid = pthread_self();
WorkerThread(Kwave::Runnable *runnable, QVariant params)
static bool g_signal_handler_is_in_place
#define MAX_ATTEMPTS_TO_STOP
virtual void run_wrapper(const QVariant ¶ms)=0
void _dummy_SIGHUP_handler(int)
virtual int stop(unsigned int timeout=10000)
virtual void run() Q_DECL_OVERRIDE
Kwave::Runnable * m_runnable
virtual ~WorkerThread() Q_DECL_OVERRIDE