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., to send some intermediate result to the GUI). 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) |
![]() | |
BackgroundTask (void *owner) | |
Creates a new task with given owner . More... | |
virtual | ~BackgroundTask () |
virtual void | run ()=0 |
Method that needs to be reimplemented. This is called from the worker thread. More... | |
bool | isSynchronous () const |
Checks whether the task is synchronous, which means it is not executed in a different thread. More... | |
void | setSynchronous (bool flag) |
Sets whether the task is handled synchronously. Call this only in the setup of the task, not while it is already running. More... | |
void | setSynchronousCancelField (NotifyField *field) |
Sets a cancel field that is used in synchronous mode to check whether cancel was pressed. More... | |
Status | status () const |
Returns the status of the task. More... | |
void | cancel () |
Cancels the task (i.e., it sets status to canceled). More... | |
bool | isCanceled () const |
Checks whether the task was canceled. More... | |
bool | shouldStop () |
Returns whether the task should stop its work because it has been canceled. More... | |
void | resume () |
Resumes the task after it was suspended. More... | |
void | suspend () |
Suspends the task. More... | |
std::string | statusString () const |
Returns current status string. More... | |
virtual void | setStatusString (const std::string &status) |
Updates the status string while processing. More... | |
float | progress () const |
Returns current progress This is thread-safe. More... | |
virtual void | setProgress (float progress) |
Updates the progress while processing. More... | |
void | setOwnerWasDeleted () |
Tells the task that its owner was deleted and cancels the thread. More... | |
bool | hasOwner () const |
Returns whether the owner was deleted. More... | |
void * | owner () const |
Returns the owner of the task Call this from GUI thread only! More... | |
void | waitAndExecuteNextMessage () |
Executes the next message. More... | |
bool | executeNextMessage () |
Executes the next message. More... | |
void | sendMessageToGUI (BackgroundTaskMessage *message) |
Sends the message to the GUI. More... | |
void | logMessage (const std::string &message) |
Logs a message. More... | |
bool | isVerbose () const |
Checks whether task uses verbose logging. More... | |
void | setVerbose (bool flag) |
Sets whether task uses verbose logging. More... | |
double | runningTime () const |
Returns the running time in seconds of the task. More... | |
double | idleTime () const |
Returns the idle time in seconds of the task (e.g., the time it waited for getTile to complete). More... | |
void | getStatusInformation (BackgroundTaskStatusInformation &info) |
Returns the complete status information. More... | |
MLuint32 | taskId () const |
Returns the unique id of this task. The id of a task never changes. More... | |
void | setTaskFinishedCB (BackgroundTaskFinishedCB *callback, void *userdata) |
Set this directly after the initialization of the task from the GUI thread. More... | |
void | addObserver (Observer *observer) |
Adds the given observer. More... | |
void | removeObserver (Observer *observer) |
Removes the given observer. More... | |
Additional Inherited Members | |
![]() | |
enum | Status { NotInTaskManager , Queued , Running , Finished , Canceled , Suspended } |
Defines current status of the task. More... | |
![]() | |
void | sendStatusChangedToObservers () |
Sends the status change to all observers. More... | |
void | sendStatusStringChangedToObservers () |
Sends the status string change to all observers. More... | |
void | sendLogMessageToObservers (const std::string &msg) |
Sends the status string change to all observers. More... | |
void | addIdleTime (double timeInSecs) |
Adds given timeInSecs as spent idle time. More... | |
MessagingBackgroundTask extends the BackgroundTask with the functionality to call methods on DistantObject instances on the GUI thread to communicate with the GUI (e.g., to 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 five 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 sent 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 boost::get(), ml::NewBackgroundTaskMethodCall(), ml::BackgroundTask::sendMessageToGUI(), and boost::target().
|
inline |
Definition at line 84 of file mlMessagingBackgroundTask.h.
References boost::get(), ml::NewBackgroundTaskMethodCall(), ml::BackgroundTask::sendMessageToGUI(), and boost::target().
|
inline |
Definition at line 90 of file mlMessagingBackgroundTask.h.
References boost::get(), ml::NewBackgroundTaskMethodCall(), ml::BackgroundTask::sendMessageToGUI(), and boost::target().
|
inline |
Definition at line 96 of file mlMessagingBackgroundTask.h.
References boost::get(), ml::NewBackgroundTaskMethodCall(), ml::BackgroundTask::sendMessageToGUI(), and boost::target().
|
inline |
Definition at line 102 of file mlMessagingBackgroundTask.h.
References boost::get(), ml::NewBackgroundTaskMethodCall(), ml::BackgroundTask::sendMessageToGUI(), and boost::target().
|
inline |
Definition at line 108 of file mlMessagingBackgroundTask.h.
References boost::get(), ml::NewBackgroundTaskMethodCall(), ml::BackgroundTask::sendMessageToGUI(), and boost::target().