MeVisLab Toolbox Reference
mlBackgroundTaskHandle.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2009, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_BACKGROUND_TASK_HANDLE_H
14#define ML_BACKGROUND_TASK_HANDLE_H
15
16// Local includes
18
20
21//-----------------------------------------------------------------------
22
23class BackgroundTask;
24
26
31{
32public:
33 BackgroundTaskHandle() { _task = nullptr; }
34
36 void clear();
37
39 bool hasTask() const;
40
42 bool hasRunningTask() const;
43
45 bool isCanceled() const;
46
48 void cancel();
49
52
53protected:
57
59};
60
65{
66public:
67 inline static BackgroundTask* get(const BackgroundTaskHandle& handle) { return handle._task; }
68};
69
71
72#endif
73
74
#define MLBACKGROUNDTASKS_EXPORT
Project global and OS specific declarations.
This class offers direct access to the contained background task.
static BackgroundTask * get(const BackgroundTaskHandle &handle)
A handle to a task that has been created by the background task manager.
bool isCanceled() const
check if the task was canceled
void clear()
clears the handle, make sure to call this from the taskFinishedCB of the background task manager
bool hasTask() const
check if the handle has a task
BackgroundTaskHandle(BackgroundTask *task)
void setOwnerWasDeleted()
tell the task that the owner was deleted
void cancel()
cancel the running task
bool hasRunningTask() const
check if the handle has a task which is not canceled
the BackgroundTaskManager is the central singleton that manages running background tasks
Base class for a task that is started in an extra thread.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.