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 | ) |
|
add an observer (the ownership stays with the caller)
◆ cancelPendingRequestsForTask()
cancel pending requests for a given task
◆ cleanup()
static void ml::BackgroundTaskManager::cleanup |
( |
| ) |
|
|
static |
cleanup 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 thus a worker thread) NOTE: in synchronous mode, this will always return true, don't use it to decide on the code path, use ensureGUIThread instead.
◆ getBackgroundTaskScheduleProcessPendingMessagesCB()
Get the currently set callback.
◆ getPageRequestProcessor()
get instance of the page request processor (TODO: this will probably move into the ML host!)
◆ getStatusInformation()
get a snapshot of the state of all background tasks (which will represent that consistent status at the time of calling this function)
◆ getUniqueTaskId()
MLuint32 ml::BackgroundTaskManager::getUniqueTaskId |
( |
| ) |
|
|
protected |
get new unique id of a task (threadsafe)
◆ hasSynchronousTask()
bool ml::BackgroundTaskManager::hasSynchronousTask |
( |
| ) |
const |
|
inline |
◆ init()
initialize 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 if more work is available.
◆ removeMessagesForReceiver()
remove all messages for receiver from the GUI message queue.
◆ removeObserver()
void ml::BackgroundTaskManager::removeObserver |
( |
Observer * | observer | ) |
|
remove an observer (the ownership stays with the caller)
◆ removeTaskFromQueueAndSendTaskFinished()
void ml::BackgroundTaskManager::removeTaskFromQueueAndSendTaskFinished |
( |
BackgroundTask * | task | ) |
|
|
protected |
remove a task if it was queued
◆ runTask()
run the given task, the ownership of the task is transfered to the task manager (do NOT delete the task yourself!) (only call from GUI thread!)
◆ self()
◆ sendMessageToGUI()
sends the given message asynchronously to the to the GUI thread, the message ownership is passed to the manager, do NOT delete it youself!
◆ 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 youself!
◆ sendTaskAdded()
send task added to observers
◆ sendTaskFinishedMessage()
called by worker threads when a task is finished
◆ sendTaskRemoved()
send task removed to observers
◆ sendTaskStatusUpdated()
void ml::BackgroundTaskManager::sendTaskStatusUpdated |
( |
| ) |
|
|
protected |
send task status updated to observers
◆ setBackgroundTaskScheduleProcessPendingMessagesCB()
Set 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 threadsafe and should cause a call to the processPendingMessages() in the GUI thread, best from within an idle timer to not block the GUI. If this callback is not installed, the BackgroundTaskManager will only run synchronous tasks. It should be setup in the early initialization phase of an application. NOTE: you MAY NOT change this while an asynchronous background task is running!!!
◆ supportsAsynchronousTasks()
bool ml::BackgroundTaskManager::supportsAsynchronousTasks |
( |
| ) |
|
Returns if 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 (only valid in GUI thread)
◆ waitForTask()
waits for a new task, returns the new task from the queue
◆ BackgroundTask
◆ BackgroundTaskFinishedMessage
◆ BackgroundTaskManagerPrivate
◆ BackgroundTaskManagerWorkerFunc
The documentation for this class was generated from the following file: