MeVisLab Toolbox Reference
|
The TypedBackgroundTaskHandle class provides a secure interface to communicate with a running BackgroundTask. More...
#include <mlTypedBackgroundTaskHandle.h>
Public Types | |
typedef Task | TaskType |
Typedef to access the type of the stored task. More... | |
Public Member Functions | |
TypedBackgroundTaskHandle () | |
TypedBackgroundTaskHandle (Task *task) | |
TypedBackgroundTaskHandle & | operator= (Task *task) |
Calling methods on the running task | |
template<typename Method > | |
void | callMethodOnTask (Method method) |
template<typename Method , typename Arg1 > | |
void | callMethodOnTask (Method method, const Arg1 &arg1) |
template<typename Method , typename Arg1 , typename Arg2 > | |
void | callMethodOnTask (Method method, const Arg1 &arg1, const Arg2 &arg2) |
template<typename Method , typename Arg1 , typename Arg2 , typename Arg3 > | |
void | callMethodOnTask (Method method, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) |
template<typename Method , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 > | |
void | callMethodOnTask (Method method, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) |
template<typename Method , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 > | |
void | callMethodOnTask (Method method, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) |
Public Member Functions inherited from ml::BackgroundTaskHandle | |
BackgroundTaskHandle () | |
void | clear () |
clears the handle, make sure to call this from the taskFinishedCB of the background task manager More... | |
bool | hasTask () const |
check if the handle has a task More... | |
bool | hasRunningTask () const |
check if the handle has a task which is not canceled More... | |
bool | isCanceled () const |
check if the task was canceled More... | |
void | cancel () |
cancel the running task More... | |
void | setOwnerWasDeleted () |
tell the task that the owner was deleted More... | |
Protected Member Functions | |
Task * | typedTask () const |
get access to the typed task value More... | |
Protected Member Functions inherited from ml::BackgroundTaskHandle | |
BackgroundTaskHandle (BackgroundTask *task) | |
Additional Inherited Members | |
Protected Attributes inherited from ml::BackgroundTaskHandle | |
BackgroundTask * | _task |
The TypedBackgroundTaskHandle class provides a secure interface to communicate with a running BackgroundTask.
It provides the callMethodOnTask() methods to call a method on the task in the thread the task is running in. It does not provide return values. The handle DOES NOT reset to NULL when the task is destroyed, so the programmer needs to make sure that the clear() method is called when the task is gone. In the case of the BackgroundTaskBaseModule, the correct place to do this is the virtual taskFinished() method. NOTE: Sending method calls to a running task is very seldom needed and requires that the task actively calls executeNextMessage() to process the incoming calls.
Definition at line 41 of file mlTypedBackgroundTaskHandle.h.
typedef Task ml::TypedBackgroundTaskHandle< Task >::TaskType |
Typedef to access the type of the stored task.
Definition at line 45 of file mlTypedBackgroundTaskHandle.h.
|
inline |
Definition at line 47 of file mlTypedBackgroundTaskHandle.h.
|
inline |
Definition at line 49 of file mlTypedBackgroundTaskHandle.h.
|
inline |
The example below shows how to use the handle. Note that you would typically store the handle as a member variable and would call callMethodOnTask at a much later time to tell the task that something changed.
callMethodOnTask() can call any non-static member method of the task 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.
Definition at line 83 of file mlTypedBackgroundTaskHandle.h.
References ml::NewBackgroundTaskMethodCall().
|
inline |
Definition at line 89 of file mlTypedBackgroundTaskHandle.h.
References ml::NewBackgroundTaskMethodCall().
|
inline |
Definition at line 95 of file mlTypedBackgroundTaskHandle.h.
References ml::NewBackgroundTaskMethodCall().
|
inline |
Definition at line 101 of file mlTypedBackgroundTaskHandle.h.
References ml::NewBackgroundTaskMethodCall().
|
inline |
Definition at line 107 of file mlTypedBackgroundTaskHandle.h.
References ml::NewBackgroundTaskMethodCall().
|
inline |
Definition at line 113 of file mlTypedBackgroundTaskHandle.h.
References ml::NewBackgroundTaskMethodCall().
|
inline |
Definition at line 51 of file mlTypedBackgroundTaskHandle.h.
|
inlineprotected |
get access to the typed task value
Definition at line 122 of file mlTypedBackgroundTaskHandle.h.