Marble

AbstractWorkerThread.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2009 Bastian Holst <[email protected]>
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 
15 namespace Marble
16 {
17 
18 class 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  */
31 class MARBLE_EXPORT AbstractWorkerThread : public QThread
32 {
33  Q_OBJECT
34 
35  public:
36  explicit AbstractWorkerThread( QObject *parent = nullptr );
37  ~AbstractWorkerThread() override;
38 
39  void ensureRunning();
40 
41  protected:
42  virtual bool workAvailable() = 0;
43  virtual void work() = 0;
44 
45  void run() override;
46 
47  private:
48  AbstractWorkerThreadPrivate * const d;
49 };
50 
51 }
52 
53 #endif
Binds a QML item to a specific geodetic location in screen coordinates.
The AbstractWorkerThread is a class written for small tasks that have to run multiple times on differ...
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:12:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.