![]() |
Fréchet View
1.6.0
A Tool for Exploring Fréchet Distance Algorithms
|
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.
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 | |
WorkerJobHandle * | handle |
reference to thread-safe handle More... | |
Friends | |
class | WorkerJobHandle |
|
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.
|
overridevirtual |
abstract method that performs the long-running task
Definition at line 45 of file workerthread.cpp.
|
pure virtual |
abstract method for starting the job
Implemented in frechet::k::KWorkerJob, and frechet::poly::PolygonWorkerJob.
|
friend |
Definition at line 51 of file workerthread.h.
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.
|
private |
reference to thread-safe handle
Definition at line 53 of file workerthread.h.