Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
frechet::app::WorkerJob Class Referenceabstract

Detailed Description

Background job to run long-runner tasks in a seperate thread.

Implements QRunnable and is scheduled in a global QThreadPool.

Long-running tasks include the algorithms for simple polygons, and the k-Fréchet "brute-force" algorithms.

Jobs can be cancelled by setting the cancelled flag.

When the WorkerJob object is passed to QThreadPool, the thread pool takes ownership of the object. We must exert some care when accessing a pointer to WorkerJob. WorkerJobHandle takes care of that.

Author
Peter Schäfer

Definition at line 48 of file workerthread.h.

#include <workerthread.h>

Inherits QRunnable.

Inherited by frechet::k::KWorkerJob, and frechet::poly::PolygonWorkerJob.

Public Member Functions

virtual void runJob ()=0
 abstract method for starting the job More...
 
virtual void afterInterrupted ()=0
 
virtual void run () override
 abstract method that performs the long-running task More...
 

Public Attributes

volatile bool cancelRequested
 cancellation flag More...
 

Private Attributes

WorkerJobHandlehandle
 reference to thread-safe handle More...
 

Friends

class WorkerJobHandle
 

Member Function Documentation

◆ afterInterrupted()

virtual void frechet::app::WorkerJob::afterInterrupted ( )
pure virtual

abstract method that is called after the job was interrupted. Implementors can use this method to clean up resources.

Implemented in frechet::k::KWorkerJob, and frechet::poly::PolygonWorkerJob.

◆ run()

void WorkerJob::run ( )
overridevirtual

abstract method that performs the long-running task

Definition at line 45 of file workerthread.cpp.

◆ runJob()

virtual void frechet::app::WorkerJob::runJob ( )
pure virtual

abstract method for starting the job

Implemented in frechet::k::KWorkerJob, and frechet::poly::PolygonWorkerJob.

Friends And Related Function Documentation

◆ WorkerJobHandle

friend class WorkerJobHandle
friend

Definition at line 51 of file workerthread.h.

Member Data Documentation

◆ cancelRequested

volatile bool frechet::app::WorkerJob::cancelRequested

cancellation flag

This flag is set by the application when the user requests the interruption of a long-running taks (usually by clicking the 'Stop' button).

Algorithm implementations are expected to poll this flag regularly. When the flag is set, an InterruptedException is thrown and caught by the run() method.

Note that the variable is declared volatile because it will be accessed from different threads.

Definition at line 66 of file workerthread.h.

◆ handle

WorkerJobHandle* frechet::app::WorkerJob::handle
private

reference to thread-safe handle

Definition at line 53 of file workerthread.h.


The documentation for this class was generated from the following files: