|
Albert
|
#include <albert/backgroundexecutor.h>
Convenience class for recurring indexing tasks.
Takes care of the QtConcurrent boilerplate code to start, abort and schedule restarts of threads.
Public Member Functions | |
| BackgroundExecutor ()=default | |
| Constructs the background executor. | |
| ~BackgroundExecutor () | |
| Destructs the background executor. | |
| void | run () |
| Run or schedule a rerun of the task. | |
| void | stop () |
| Stops the current execution. | |
| bool | isRunning () const |
Returns true if the asynchronous computation is currently running; otherwise returns false. | |
| void | waitForFinished () |
| Blocks until the current task finished. | |
| T | takeResult () |
| Takes the result from the future. | |
Public Attributes | |
| std::function< T(const bool &abort)> | parallel |
| The task to be executed in a thread. | |
| std::function< void()> | finish |
| The finish callback. | |
|
default |
Constructs the background executor.
|
inline |
Destructs the background executor.
Silently blocks execution until a running task is finished. See isRunning() and waitForFinished().
|
inline |
Returns true if the asynchronous computation is currently running; otherwise returns false.
|
inline |
Run or schedule a rerun of the task.
If a task is running this function sets the abort flag and schedules a rerun. finish will not be called for the cancelled run.
|
inline |
Stops the current execution.
|
inline |
|
inline |
Blocks until the current task finished.
| std::function<void()> albert::BackgroundExecutor< T >::finish |
The finish callback.
When the parallel function finished, this function will be called in the main thread. Use BackgroundExecutor::takeResult to get the results returned from parallel.
| std::function<T(const bool &abort)> albert::BackgroundExecutor< T >::parallel |
The task to be executed in a thread.
Return the results of type T. Abort if abort is true.