The BackgroundTaskManager is the central singleton that manages running background tasks.
More...
#include <mlBackgroundTaskManager.h>
The BackgroundTaskManager is the central singleton that manages running background tasks.
Definition at line 53 of file mlBackgroundTaskManager.h.
◆ addObserver()
void ml::BackgroundTaskManager::addObserver |
( |
Observer * |
observer | ) |
|
Adds an observer (the ownership stays with the caller).
◆ cancelPendingRequestsForTask()
void ml::BackgroundTaskManager::cancelPendingRequestsForTask |
( |
BackgroundTask * |
task | ) |
|
Cancels pending requests for a given task.
◆ cleanup()
static void ml::BackgroundTaskManager::cleanup |
( |
| ) |
|
|
static |
Cleans up the background task manager.
◆ ensureGUIThread()
static bool ml::BackgroundTaskManager::ensureGUIThread |
( |
| ) |
|
|
static |
Returns true
if the current thread is the GUI thread.
◆ ensureWorkerThread()
static bool ml::BackgroundTaskManager::ensureWorkerThread |
( |
| ) |
|
|
static |
Returns true
if the current thread is not the GUI thread and is thus a worker thread.
Note: in synchronous mode, this will always return true
. Do not use it to decide on the code path; use ensureGUIThread instead.
◆ getBackgroundTaskScheduleProcessPendingMessagesCB()
Gets the currently set callback.
◆ getPageRequestProcessor()
Returns instance of the page request processor (TODO: this will probably move into the ML host!).
◆ getStatusInformation()
Gets a snapshot of the state of all background tasks, representing the consistent status at the time of calling this function.
◆ getUniqueTaskId()
MLuint32 ml::BackgroundTaskManager::getUniqueTaskId |
( |
| ) |
|
|
protected |
Returns new unique id of a task.
This is thread-safe.
◆ hasSynchronousTask()
bool ml::BackgroundTaskManager::hasSynchronousTask |
( |
| ) |
const |
|
inline |
◆ init()
static void ml::BackgroundTaskManager::init |
( |
| ) |
|
|
static |
Initializes the background task manager.
◆ processPendingMessages()
bool ml::BackgroundTaskManager::processPendingMessages |
( |
| ) |
|
Processes all pending messages (will not block and may only be called from the GUI thread, typically from an idle timer).
Returns whether more work is available.
◆ removeMessagesForReceiver()
Removes all messages for receiver from the GUI message queue.
◆ removeObserver()
void ml::BackgroundTaskManager::removeObserver |
( |
Observer * |
observer | ) |
|
Removes an observer (the ownership stays with the caller).
◆ removeTaskFromQueueAndSendTaskFinished()
void ml::BackgroundTaskManager::removeTaskFromQueueAndSendTaskFinished |
( |
BackgroundTask * |
task | ) |
|
|
protected |
Removes a task
if it was queued.
◆ runTask()
Runs the given task.
The ownership of the task is transfered to the task manager. Do not delete the task yourself! Only call this from the GUI thread!
◆ self()
Returns the global singleton.
◆ sendMessageToGUI()
Sends the given message asynchronously to the GUI thread.
The message ownership is passed to the manager. Do not delete it yourself!
◆ sendMessageToTask()
Sends the given message asynchronously to the worker thread of the task.
The message ownership is passed to the manager. Do not delete it yourself!
◆ sendTaskAdded()
void ml::BackgroundTaskManager::sendTaskAdded |
( |
BackgroundTask * |
task | ) |
|
|
protected |
Sends a task
that is added to the observers.
◆ sendTaskFinishedMessage()
void ml::BackgroundTaskManager::sendTaskFinishedMessage |
( |
BackgroundTask * |
task | ) |
|
|
protected |
Called by worker threads when a task is finished.
◆ sendTaskRemoved()
void ml::BackgroundTaskManager::sendTaskRemoved |
( |
BackgroundTask * |
task | ) |
|
|
protected |
Sends a task
that is removed from the observers.
◆ sendTaskStatusUpdated()
void ml::BackgroundTaskManager::sendTaskStatusUpdated |
( |
| ) |
|
|
protected |
Sends that a task's status is updated to the observers.
◆ setBackgroundTaskScheduleProcessPendingMessagesCB()
Sets the callback that will be called from any worker thread when a call of processPendingMessages() on the GUI thread is required.
It needs to be thread-safe and should cause a call to processPendingMessages() in the GUI thread, ideally from within an idle timer to avoid blocking the GUI. If this callback is not installed, the BackgroundTaskManager will only run synchronous tasks. It should be set up in the early initialization phase of an application. Note: you must not change this while an asynchronous background task is running!
◆ supportsAsynchronousTasks()
bool ml::BackgroundTaskManager::supportsAsynchronousTasks |
( |
| ) |
|
Returns whether asynchronous tasks are supported, which is the case if setBackgroundTaskScheduleProcessPendingMessagesCB was called with a non-NULL callback.
◆ totalTaskCount()
int ml::BackgroundTaskManager::totalTaskCount |
( |
| ) |
|
Returns the number of queued and running tasks.
This is only valid in the GUI thread.
◆ waitForTask()
Waits for a new task and returns the new task from the queue.
◆ BackgroundTask
◆ BackgroundTaskFinishedMessage
◆ BackgroundTaskManagerPrivate
friend class BackgroundTaskManagerPrivate |
|
friend |
◆ BackgroundTaskManagerWorkerFunc
friend struct BackgroundTaskManagerWorkerFunc |
|
friend |
The documentation for this class was generated from the following file: