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) |
![]() | |
BackgroundTaskHandle () | |
void | clear () |
Clears the handle. Make sure to call this from the taskFinishedCB of the background task manager. More... | |
bool | hasTask () const |
Returns whether the handle has a task. More... | |
bool | hasRunningTask () const |
Returns whether the handle has a task that is not canceled. More... | |
bool | isCanceled () const |
Returns whether the task was canceled. More... | |
void | cancel () |
Cancels the running task. More... | |
void | setOwnerWasDeleted () |
Tells the task that the owner was deleted. More... | |
Protected Member Functions | |
Task * | typedTask () const |
Returns access to the typed task value. More... | |
![]() | |
BackgroundTaskHandle (BackgroundTask *task) | |
Additional Inherited Members | |
![]() | |
BackgroundTask * | _task |
The TypedBackgroundTaskHandle class provides a secure interface to communicate with a running BackgroundTask.
It offers the callMethodOnTask() methods to invoke a method on the task in the thread that the task is running in. It does not provide return values. The handle does not reset to NULL when the task is destroyed. The programmer needs to ensure 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 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.
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 |
Returns access to the typed task value.
Definition at line 122 of file mlTypedBackgroundTaskHandle.h.