Abstract base class for QObject-based workers that run in a dedicated QThread.
More...
#include <abstractthreadclass.h>
|
|
void | started () |
| | Emitted when the worker thread has started.
|
| |
|
void | finished () |
| | Emitted when the worker thread has finished.
|
| |
|
| virtual void | threadStarted ()=0 |
| | Entry point called on the worker thread immediately after it starts.
|
| |
| virtual void | threadFinished () |
| | Called on the worker thread just before it exits.
|
| |
| bool | waitForStart (const TimeSpan &timeout) |
| | Block until the thread has entered threadStarted() or the timeout elapses.
|
| |
| void | finishAndStop (bool success, const QString &message=QString()) |
| | Signal that the worker has finished, recording success and a message.
|
| |
| void | writeLine (const QString &line) |
| | Write a line to the standard output stream.
|
| |
| void | writeErrorLine (const QString &line) |
| | Write a line to the standard error stream.
|
| |
| Log::LogCategory | LVL0 () const |
| | Return the base (level 0) log category.
|
| |
| Log::LogCategory | LVL1 () const |
| | Return the level-1 sub-category.
|
| |
| Log::LogCategory | LVL2 () const |
| | Return the level-2 sub-category.
|
| |
| Log::LogCategory | LVL3 () const |
| | Return the level-3 sub-category.
|
| |
| void | logText (const char *file, int lineNumber, Log::LogLevel level, const QString &text) const |
| | Write a text message to the system logger using the base category.
|
| |
| void | logText (const char *file, int lineNumber, Log::LogLevel level, const Log::LogCategory &category, const QString &text) const |
| | Write a text message to the system logger using an explicit category.
|
| |
| void | logHex (const char *file, int lineNumber, Log::LogLevel level, const QByteArray &data, const QString &tag=QString()) const |
| | Write a hex dump to the system logger.
|
| |
| void | logHex (const char *file, int lineNumber, Log::LogLevel level, const Log::LogCategory &category, const QByteArray &data, const QString &tag=QString()) const |
| | Write a hex dump to the system logger using an explicit category.
|
| |
| void | addLogConsumer (LogConsumer *consumer) |
| | Register an external log consumer to receive entries from this class.
|
| |
| void | removeLogConsumer (LogConsumer *consumer) |
| | Remove a previously added log consumer.
|
| |
Abstract base class for QObject-based workers that run in a dedicated QThread.
Manages the lifecycle of a QObject running in its own QThread.
Subclass AbstractThreadClass and implement threadStarted() to perform work on the worker thread. The thread is created and destroyed automatically by start() and stop(). The started() and finished() signals notify the main thread of state changes.
Definition at line 25 of file abstractthreadclass.h.
◆ AbstractThreadClass() [1/2]
Construct with an optional log category and parent.
- Parameters
-
| category | Log category for this class (default: uncategorized) |
| parent | Optional QObject parent |
◆ AbstractThreadClass() [2/2]
| AbstractThreadClass::AbstractThreadClass |
( |
const QString & |
category, |
|
|
QObject * |
parent = nullptr |
|
) |
| |
Construct with a category name string and optional parent.
- Parameters
-
| category | Category name string |
| parent | Optional QObject parent |
◆ completionMessage()
| QString AbstractThreadClass::completionMessage |
( |
| ) |
const |
|
inline |
◆ finishAndStop()
| void AbstractThreadClass::finishAndStop |
( |
bool |
success, |
|
|
const QString & |
message = QString() |
|
) |
| |
|
protected |
Signal that the worker has finished, recording success and a message.
- Parameters
-
| success | Whether the work completed successfully |
| message | Optional human-readable completion message |
◆ isRunning()
| bool AbstractThreadClass::isRunning |
( |
| ) |
const |
|
inline |
Test whether the worker thread is currently running.
- Returns
- true if the thread is running
Definition at line 76 of file abstractthreadclass.h.
◆ isStopping()
| bool AbstractThreadClass::isStopping |
( |
| ) |
const |
|
inline |
Test whether stop() has been called and the thread is winding down.
- Returns
- true if stopping is in progress
Definition at line 82 of file abstractthreadclass.h.
◆ setBlockingStart()
| void AbstractThreadClass::setBlockingStart |
( |
bool |
value | ) |
|
|
inline |
◆ start()
Start the worker thread and optionally wait for it to signal readiness.
- Parameters
-
| timeout | How long to wait for the thread to start (zero = don't wait) |
- Returns
- true if the thread started successfully
◆ stop()
Request the worker thread to stop and optionally wait for it to finish.
- Parameters
-
| timeout | How long to wait for the thread to finish (zero = don't wait) |
- Returns
- true if the thread stopped within the timeout
◆ success()
| bool AbstractThreadClass::success |
( |
| ) |
const |
|
inline |
◆ threadFinished()
| virtual void AbstractThreadClass::threadFinished |
( |
| ) |
|
|
inlineprotectedvirtual |
◆ threadStarted()
| virtual void AbstractThreadClass::threadStarted |
( |
| ) |
|
|
protectedpure virtual |
Entry point called on the worker thread immediately after it starts.
Subclasses must implement this method to perform their work. When done, call finishAndStop() to signal completion.
◆ waitForCompletion()
Block until the worker thread finishes or the timeout elapses.
- Parameters
-
| timeout | Maximum wait duration (zero = wait indefinitely) |
- Returns
- true if the thread finished within the timeout
◆ waitForStart()
| bool AbstractThreadClass::waitForStart |
( |
const TimeSpan & |
timeout | ) |
|
|
protected |
Block until the thread has entered threadStarted() or the timeout elapses.
- Parameters
-
| timeout | Maximum wait duration |
- Returns
- true if the thread started within the timeout
◆ writeErrorLine()
| void AbstractThreadClass::writeErrorLine |
( |
const QString & |
line | ) |
|
|
inlineprotected |
◆ writeLine()
| void AbstractThreadClass::writeLine |
( |
const QString & |
line | ) |
|
|
inlineprotected |
The documentation for this class was generated from the following file: