1 | /* |
2 | SPDX-FileCopyrightText: 2022 David Faure <faure@kde.org> |
3 | SPDX-License-Identifier: LGPL-2.0-or-later |
4 | */ |
5 | |
6 | #ifndef KIO_WORKERTHREAD_H |
7 | #define KIO_WORKERTHREAD_H |
8 | |
9 | #include <QMutex> |
10 | #include <QThread> |
11 | |
12 | namespace KIO |
13 | { |
14 | |
15 | class SlaveBase; |
16 | class WorkerFactory; |
17 | class WorkerThread : public QThread |
18 | { |
19 | Q_OBJECT |
20 | public: |
21 | WorkerThread(QObject *parent, WorkerFactory *factory, const QByteArray &appSocket); |
22 | ~WorkerThread() override; |
23 | |
24 | void abort(); |
25 | |
26 | protected: |
27 | void run() override; |
28 | |
29 | private: |
30 | void setWorker(KIO::SlaveBase *worker); |
31 | |
32 | WorkerFactory *m_factory; // set by constructor, no mutex needed |
33 | QByteArray m_appSocket; // set by constructor, no mutex needed |
34 | |
35 | QMutex m_workerMutex; // protects m_worker, accessed by both threads |
36 | KIO::SlaveBase *m_worker = nullptr; |
37 | }; |
38 | |
39 | } // namespace KIO |
40 | |
41 | #endif // KIO_WORKERTHREAD_H |
42 | |