ThreadWeaver::Thread Class
class ThreadWeaver::ThreadThread represents a worker thread in a Queue's inventory. More...
Header: | #include <ThreadWeaver/Thread> |
CMake: | find_package(KF6 REQUIRED COMPONENTS ThreadWeaver) target_link_libraries(mytarget PRIVATE KF6::ThreadWeaver) |
Inherits: | QThread |
Public Functions
Thread(ThreadWeaver::Weaver *parent = nullptr) | |
virtual | ~Thread() override |
unsigned int | id() const |
void | requestAbort() |
Reimplemented Public Functions
virtual void | run() override |
Detailed Description
Threads are created and managed by queues on demand. A Thread will try to retrieve and process jobs from the queue until it is told to exit.
Member Function Documentation
[explicit]
Thread::Thread(ThreadWeaver::Weaver *parent = nullptr)
Create a thread.
parent the parent Weaver
[override virtual noexcept]
Thread::~Thread()
The destructor.
unsigned int Thread::id() const
Returns the thread id.
This id marks the respective Thread object, and must therefore not be confused with, e.g., the pthread thread ID. The way threads are implemented and identified is platform specific. id() is the only way to uniquely identify a thread within ThreadWeaver.
void Thread::requestAbort()
Request the abortion of the job that is processed currently.
If there is no current job, this method will do nothing, but can safely be called. It forwards the request to the current Job.
[override virtual]
void Thread::run()
Reimplements: QThread::run().
The run method is reimplemented to execute jobs from the queue.
Whenever the thread is idle, it will ask its Weaver parent for a Job to do. The Weaver will either return a Job or a null pointer. When a null pointer is returned, it tells the thread to exit.