MeVisLab Toolbox Reference
|
MessagingBackgroundTask extends the BackgroundTask with the functionality to call methods on DistantObject instances on the GUI thread to communicate with the GUI (e.g. More...
#include <mlMessagingBackgroundTask.h>
Public Member Functions | |
MessagingBackgroundTask (void *ownerArg) | |
Calling methods on DistantObjects in the GUI thread | |
template<typename Object , typename Method > | |
void | callMethodOnGUI (const DistantObject< Object > &target, Method method) |
template<typename Object , typename Method , typename Arg1 > | |
void | callMethodOnGUI (const DistantObject< Object > &target, Method method, const Arg1 &arg1) |
template<typename Object , typename Method , typename Arg1 , typename Arg2 > | |
void | callMethodOnGUI (const DistantObject< Object > &target, Method method, const Arg1 &arg1, const Arg2 &arg2) |
template<typename Object , typename Method , typename Arg1 , typename Arg2 , typename Arg3 > | |
void | callMethodOnGUI (const DistantObject< Object > &target, Method method, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) |
template<typename Object , typename Method , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 > | |
void | callMethodOnGUI (const DistantObject< Object > &target, Method method, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) |
template<typename Object , typename Method , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 > | |
void | callMethodOnGUI (const DistantObject< Object > &target, Method method, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) |
Public Member Functions inherited from ml::BackgroundTask | |
BackgroundTask (void *owner) | |
Create a new task with given owner (the owner can be used to associate the task with a given class instance, e.g. | |
virtual | ~BackgroundTask () |
virtual void | run ()=0 |
run method that needs to be reimplemented (called from worker thread) | |
bool | isSynchronous () const |
check if task is synchronous (which means it is NOT run in an extra thread) | |
void | setSynchronous (bool flag) |
set if task is handled synchronous (call this ONLY on setup of the task, not while it is already running) | |
void | setSynchronousCancelField (NotifyField *field) |
set a cancel field that is used in synchronous mode to check if cancel was pressed | |
Status | status () const |
returns the status of the task (threadsafe) | |
void | cancel () |
cancel the task (sets status to canceled) (threadsafe, typically called from GUI) | |
bool | isCanceled () const |
check if the task was canceled (threadsafe, typically called from GUI) | |
bool | shouldStop () |
returns if the task should stop its work because it has been canceled. | |
void | resume () |
resume task after it was suspended (will only do something if current status() is Suspended) (threadsafe) | |
void | suspend () |
suspend task, so that it will wait until resume() is called (threadsafe). | |
std::string | statusString () const |
get current status string (threadsafe) | |
virtual void | setStatusString (const std::string &status) |
update the status string while processing (from run() method only) | |
float | progress () const |
get current progress (threadsafe) | |
virtual void | setProgress (float progress) |
update the progress while processing (from run() method only) | |
void | setOwnerWasDeleted () |
tell the task that it's owner was deleted (only call from GUI thread!), this also cancels the task | |
bool | hasOwner () const |
check if owner was deleted (only call from GUI thread!) | |
void * | owner () const |
get the owner of the task (only call from GUI thread!) | |
void | waitAndExecuteNextMessage () |
execute the next message (waits if no messages are available and processes the first message that is received) NOTE: only call from within run() | |
bool | executeNextMessage () |
execute the next message (does not block if no message is available) It returns true if there was a message to process. | |
void | sendMessageToGUI (BackgroundTaskMessage *message) |
send the message to the GUI (ownership of message is passed to the method) and it sets the sender of the message to this BackgroundTask. | |
void | logMessage (const std::string &message) |
log a message (only logged if verbose logging is turned on) (threadsafe) | |
bool | isVerbose () const |
check if task uses verbose logging | |
void | setVerbose (bool flag) |
set if task uses verbose logging (call this ONLY on setup of the task, not while it is already running) | |
double | runningTime () const |
returns the running time (in seconds) of the task (after it has finished or canceled, only call from GUI thread) | |
double | idleTime () const |
returns the idle time (in seconds) of the task (which it e.g. waited for getTile to complete), (after it has finished or canceled, only call from GUI thread) | |
void | getStatusInformation (BackgroundTaskStatusInformation &info) |
get the complete status information (threadsafe) | |
MLuint32 | taskId () const |
get the unique id of this task, the id of a task never changes | |
void | setTaskFinishedCB (BackgroundTaskFinishedCB *callback, void *userdata) |
set this directly after initialization of the task (from the GUI thread) this callback will be called whenever a task is either finished or canceled | |
void | addObserver (Observer *observer) |
add the given observer (threadsafe) (ownership stays with caller) | |
void | removeObserver (Observer *observer) |
remove the given observer (threadsafe) (ownership stays with caller) | |
Additional Inherited Members | |
Public Types inherited from ml::BackgroundTask | |
enum | Status { NotInTaskManager , Queued , Running , Finished , Canceled , Suspended } |
Defines current status of the task. More... | |
Protected Member Functions inherited from ml::BackgroundTask | |
void | sendStatusChangedToObservers () |
send the status change to all observers | |
void | sendStatusStringChangedToObservers () |
send the status string change to all observers | |
void | sendLogMessageToObservers (const std::string &msg) |
send the status string change to all observers | |
void | addIdleTime (double timeInSecs) |
add given timeInSecs as spent idle time | |
MessagingBackgroundTask extends the BackgroundTask with the functionality to call methods on DistantObject instances on the GUI thread to communicate with the GUI (e.g.
send some intermediate result to the GUI).
Definition at line 30 of file mlMessagingBackgroundTask.h.
|
inline |
Definition at line 35 of file mlMessagingBackgroundTask.h.
|
inline |
callMethodOnGUI() can call any non-static member method on the instance of T that is stored in a DistantObject<T> with up to 5 arguments, the arguments are copies so that values that you pass need to be copyable. You should be very careful when you pass pointers since the ownership stays with the caller and you can not easily know when it is safe to delete the pointer. The call is send to the GUI thread and executed there.
The example shows how to send an intermediate Matrix4 result to a MatrixField in the GUI thread:
Typically you will either pass the pointer to your derived Module and store it as a DistantObject, or alternatively you can pass individual fields and store them in their own DistantObjects.
Definition at line 78 of file mlMessagingBackgroundTask.h.
References ml::NewBackgroundTaskMethodCall(), and ml::BackgroundTask::sendMessageToGUI().
|
inline |
Definition at line 84 of file mlMessagingBackgroundTask.h.
References mlrange_cast(), ml::NewBackgroundTaskMethodCall(), and ml::BackgroundTask::sendMessageToGUI().
|
inline |
Definition at line 90 of file mlMessagingBackgroundTask.h.
References mlrange_cast(), ml::NewBackgroundTaskMethodCall(), and ml::BackgroundTask::sendMessageToGUI().
|
inline |
Definition at line 96 of file mlMessagingBackgroundTask.h.
References mlrange_cast(), ml::NewBackgroundTaskMethodCall(), and ml::BackgroundTask::sendMessageToGUI().
|
inline |
Definition at line 102 of file mlMessagingBackgroundTask.h.
References mlrange_cast(), ml::NewBackgroundTaskMethodCall(), and ml::BackgroundTask::sendMessageToGUI().
|
inline |
Definition at line 108 of file mlMessagingBackgroundTask.h.
References mlrange_cast(), ml::NewBackgroundTaskMethodCall(), and ml::BackgroundTask::sendMessageToGUI().