Base class for a long-lived worker object which lives in its own thread.
More...
|
| CContinuousWorker (QObject *owner, const QString &name) |
| Constructor. More...
|
|
void | start (QThread::Priority priority=QThread::InheritPriority) |
| Starts a thread and moves the worker into it.
|
|
void | quit () noexcept final |
| Stops the thread the next time around its event loop. The thread and the worker will then be deleted. More...
|
|
void | quitAndWait () noexcept final |
| Calls quit() and blocks until the thread is finished. More...
|
|
bool | isEnabled () const |
| Enabled (running)? More...
|
|
void | setEnabled (bool enabled) |
| Enabled (running)? More...
|
|
void | startUpdating (int updateTimeSecs) |
| Start updating (start/stop timer) More...
|
|
const QString & | getName () |
| Name of the worker.
|
|
const QObject * | owner () const |
| Owner of the worker.
|
|
template<typename T , typename F > |
void | then (T *context, F functor) |
| Connects to a functor or method which will be called when the task is finished. More...
|
|
template<typename F > |
void | then (F functor) |
| Connects to a functor which will be called when the task is finished. More...
|
|
bool | isFinished () const |
| Returns true if the task has finished. More...
|
|
template<typename F > |
void | doIfFinished (F functor) const |
| Executes some code (in the caller's thread) if the task has finished. More...
|
|
template<typename F > |
void | doIfNotFinished (F functor) const |
| Executes some code (in the caller's thread) if the task has not finished. More...
|
|
template<typename F1 , typename F2 > |
void | doIfFinishedElse (F1 ifFunctor, F2 elseFunctor) const |
| Executes some code (in the caller's thread) if the task has finished and some different code if it has not finished. More...
|
|
void | waitForFinished () noexcept |
| Blocks until the task is finished. More...
|
|
void | abandon () noexcept |
| Notify the task that its result is no longer needed, so it can finish early. More...
|
|
void | abandonAndWait () noexcept |
| Convenience to call abandon() followed by waitForFinished().
|
|
|
QTimer | m_updateTimer { this } |
| timer which can be used by implementing classes
|
|
Base class for a long-lived worker object which lives in its own thread.
Definition at line 274 of file worker.h.
◆ CContinuousWorker()
swift::misc::CContinuousWorker::CContinuousWorker |
( |
QObject * |
owner, |
|
|
const QString & |
name |
|
) |
| |
Constructor.
- Parameters
-
owner | Will be the parent of the new thread (the worker has no parent). |
name | A name for the worker, which will be used to create a name for the thread. |
Definition at line 159 of file worker.cpp.
◆ beforeQuit()
virtual void swift::misc::CContinuousWorker::beforeQuit |
( |
| ) |
|
|
inlineprotectedvirtualnoexcept |
◆ isEnabled()
bool swift::misc::CContinuousWorker::isEnabled |
( |
| ) |
const |
|
inline |
Enabled (running)?
Definition at line 300 of file worker.h.
◆ quit()
void swift::misc::CContinuousWorker::quit |
( |
| ) |
|
|
finalvirtualnoexcept |
Stops the thread the next time around its event loop. The thread and the worker will then be deleted.
Reimplemented from swift::misc::CWorkerBase.
Definition at line 193 of file worker.cpp.
◆ quitAndWait()
void swift::misc::CContinuousWorker::quitAndWait |
( |
| ) |
|
|
finalvirtualnoexcept |
Calls quit() and blocks until the thread is finished.
- Todo:
- KB 2017-10 temp workaround: in T145 this will be fixed, sometimes (very rarely) hanging here during shutdown
Reimplemented from swift::misc::CWorkerBase.
Definition at line 205 of file worker.cpp.
◆ setEnabled()
void swift::misc::CContinuousWorker::setEnabled |
( |
bool |
enabled | ) |
|
|
inline |
Enabled (running)?
Definition at line 304 of file worker.h.
◆ startUpdating()
void swift::misc::CContinuousWorker::startUpdating |
( |
int |
updateTimeSecs | ) |
|
Start updating (start/stop timer)
Definition at line 235 of file worker.cpp.
The documentation for this class was generated from the following files: