digiKam
Loading...
Searching...
No Matches
dynamicthread.h
Go to the documentation of this file.
1/* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2010-04-13
7 * Description : Dynamically active thread
8 *
9 * SPDX-FileCopyrightText: 2010-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 *
13 * ============================================================ */
14
15#pragma once
16
17// Qt includes
18
19#include <QObject>
20#include <QThread>
21#include <QRunnable>
22#include <QMutex>
23#include <QMutexLocker>
24
25// Local includes
26
27#include "digikam_export.h"
28
29namespace Digikam
30{
31
32class DIGIKAM_EXPORT DynamicThread : public QObject
33{
34 Q_OBJECT
35
36public:
37
38 enum State
39 {
43 Deactivating
44 };
45
46public:
47
52 explicit DynamicThread(QObject* const parent = nullptr);
53
59 ~DynamicThread() override;
60
64 virtual void run() = 0;
65
66 State state() const;
67 bool isRunning() const;
68 bool isFinished() const;
69
70 void setEmitSignals(bool emitThem);
71
79 void setPriority(QThread::Priority priority);
80 QThread::Priority priority() const;
81
82public Q_SLOTS:
83
84 void start();
85
89 void stop();
90
94 void wait();
95
96Q_SIGNALS:
97
101 void starting();
102 void finished();
103
104protected:
105
120 void shutDown();
121
126 bool runningFlag() const volatile;
127
135 QMutex* threadMutex() const;
136
142#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
143
144 void start(QMutexLocker<QMutex>& locker);
145 void stop(const QMutexLocker<QMutex>& locker);
146 void wait(QMutexLocker<QMutex>& locker);
147
148#else
149
150 void start(QMutexLocker& locker);
151 void stop(const QMutexLocker& locker);
152 void wait(QMutexLocker& locker);
153
154#endif
155
156private:
157
158 // Disable
159 DynamicThread(const DynamicThread&) = delete;
160 DynamicThread& operator=(const DynamicThread&) = delete;
161
162private:
163
164 friend class DynamicThreadPriv;
165
166 class Private;
167 Private* const d = nullptr;
168};
169
170} // namespace Digikam
Definition dynamicthread.h:33
virtual void run()=0
State
Definition dynamicthread.h:39
@ Scheduled
Definition dynamicthread.h:41
@ Running
Definition dynamicthread.h:42
@ Inactive
Definition dynamicthread.h:40
Definition datefolderview.cpp:34