Quark  0.1
TaskProcessor Class Reference

An object that executes Tasks in a queue on a dedicated thread. More...

#include <TaskProcessor.h++>

Inheritance diagram for TaskProcessor:

Signals

void busyStateChanged (bool busy)
 Emitted whenever the TaskProcessor switches between idle and busy state. More...
 

Public Member Functions

 TaskProcessor (QObject *parent=NULL)
 Constructs a new TaskProcessor. More...
 
virtual ~TaskProcessor ()
 Destructor. More...
 
int addTask (Task *task)
 Adds a task to the queue. More...
 
bool cancelTask (int taskId)
 Attempts to cancel a scheduled (or executing) task. More...
 
bool stop ()
 Stops the task processor. More...
 

Detailed Description

An object that executes Tasks in a queue on a dedicated thread.

The QThread start() method should be called to start the processing thread.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ TaskProcessor()

TaskProcessor ( QObject *  parent = NULL)

Constructs a new TaskProcessor.

◆ ~TaskProcessor()

virtual ~TaskProcessor ( )
virtual

Destructor.

Member Function Documentation

◆ addTask()

int addTask ( Task task)

Adds a task to the queue.

Parameters
taskThe task.
Returns
The unique ID assigned to the task.

◆ busyStateChanged

void busyStateChanged ( bool  busy)
signal

Emitted whenever the TaskProcessor switches between idle and busy state.

The TaskProcessor is "idle" when its task queue is empty.

Parameters
busyWhether the TaskProcessor is busy.

◆ cancelTask()

bool cancelTask ( int  taskId)

Attempts to cancel a scheduled (or executing) task.

Parameters
taskIdThe unique ID of the task, as returned by addTask().
Returns
true if the task was successfully cancelled, false otherwise. Some tasks may not be cancellable once they start executing.

◆ stop()

bool stop ( )

Stops the task processor.

Attempts to cancel all tasks in the queue, then stops the thread.

Returns
true if all tasks were successfully cancelled, false otherwise.

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