First step at defining interface for long running background tasks.
This commit is contained in:
parent
ee353d7da8
commit
a9534d543e
2 changed files with 53 additions and 0 deletions
1
src/core/QueuedBackgroundTask.cpp
Normal file
1
src/core/QueuedBackgroundTask.cpp
Normal file
|
|
@ -0,0 +1 @@
|
|||
#include "QueuedBackgroundTask.h"
|
||||
52
src/core/QueuedBackgroundTask.h
Normal file
52
src/core/QueuedBackgroundTask.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#pragma once
|
||||
|
||||
#include <QRunnable>
|
||||
#include <QVector>
|
||||
|
||||
/** Base class for an object that can be queued for execution in the background.
|
||||
*
|
||||
* It is meaned for long running processes the end user might want to abort, pause and check progress on.
|
||||
*/
|
||||
class QueuedBackgroundTask: public QRunnable
|
||||
{
|
||||
/** Task should exit it's run method but remember it's state, it might be resumed later.
|
||||
*/
|
||||
void requestPause();
|
||||
|
||||
/** Request to stop running and forget progress
|
||||
*/
|
||||
void requestAbort();
|
||||
|
||||
QString getProgressInfo();
|
||||
};
|
||||
|
||||
class BackgroundTaskInfo {
|
||||
public:
|
||||
};
|
||||
|
||||
/** Manages objects of type QueuedBackgroundTask
|
||||
*
|
||||
* The basic operation of this queue is hand everything directly of to the default
|
||||
* threadpool and that will decide when to run each task. But extra functions are
|
||||
* provided to control tasks to allow the program to have a UI for controlling the tasks
|
||||
*/
|
||||
class BackgroundTaskQueue {
|
||||
|
||||
public:
|
||||
|
||||
/** Returns a list of tasks in the queue and their progress.
|
||||
*
|
||||
* When building a UI to show realtime activity then make sure to first register the update events
|
||||
* then get the snapshot. After that you can use the events to update the contents of the UI.
|
||||
*/
|
||||
QVector<BackgroundTaskInfo> getTaskInfoSnapshort();
|
||||
|
||||
void pauseTask( );
|
||||
|
||||
/** Resume a paused task
|
||||
*/
|
||||
void resumeTask( );
|
||||
|
||||
void abortTask( );
|
||||
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue