Marble

AbstractWorkerThread.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de>
4//
5
6#ifndef MARBLE_ABSTRACTWORKERTHREAD_H
7#define MARBLE_ABSTRACTWORKERTHREAD_H
8
9// Marble
10#include "marble_export.h"
11
12// Qt
13#include <QThread>
14
15namespace Marble
16{
17
18class AbstractWorkerThreadPrivate;
19
20/**
21 * The AbstractWorkerThread is a class written for small tasks that have to run
22 * multiple times on different data asynchronously.
23 * You should be able to use this class for many different tasks, but you'll have to
24 * think about Multi-Threading additionally.
25 * The AbstractWorkerThread runs the function work() as long as workAvailable()
26 * returns true. If there is no work available for a longer time, the thread will
27 * switch itself off. As a result you have to call ensureRunning() every time you
28 * want something to be worked on. You'll probably want to call this in your
29 * addSchedule() function.
30 */
31class MARBLE_EXPORT AbstractWorkerThread : public QThread
32{
33 Q_OBJECT
34
35public:
36 explicit AbstractWorkerThread(QObject *parent = nullptr);
37 ~AbstractWorkerThread() override;
38
39 void ensureRunning();
40
41protected:
42 virtual bool workAvailable() = 0;
43 virtual void work() = 0;
44
45 void run() override;
46
47private:
48 AbstractWorkerThreadPrivate *const d;
49};
50
51}
52
53#endif
The AbstractWorkerThread is a class written for small tasks that have to run multiple times on differ...
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.