MeVisLab Toolbox Reference
mlMainExecutor.h
Go to the documentation of this file.
1
/*************************************************************************************
2
**
3
** Copyright 2021, 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
#pragma once
14
15
#include "
mlBackgroundTaskManager.h
"
16
#include "
mlBackgroundTaskMessage.h
"
17
18
#include <
mlTypeDefs.h
>
19
#include <stlab/concurrency/task.hpp>
20
21
ML_START_NAMESPACE
22
23
//-----------------------------------------------------------------------
27
class
MainExecutorT
28
{
29
using
result_type =
void
;
30
31
class
MainExecutorMessage
final
:
public
BackgroundTaskMessage
32
{
33
stlab::task<
void
()> _f;
34
35
public
:
36
template
<
typename
F>
37
void
setTask(
F
&& f)
38
{
39
_f = std::forward<F>(f);
40
}
41
42
void
execute()
override
43
{
44
_f();
45
}
46
};
47
48
public
:
49
52
template
<
typename
F>
53
void
operator()
(
F
f)
const
54
{
55
auto
message = std::make_unique<MainExecutorMessage>();
56
message->setTask(std::move(f));
57
BackgroundTaskManager::self().sendMessageToGUI(message.release());
58
}
59
};
60
66
constexpr
auto
MainExecutor
=
MainExecutorT
{};
67
68
ML_END_NAMESPACE
F
@ F
Definition
SoKeyGrabber.h:57
ml::BackgroundTaskMessage
The base class of all background messages.
Definition
mlBackgroundTaskMessage.h:39
ml::MainExecutorT
This class implements an executor that lets you execute a task in the ML's main loop without implemen...
Definition
mlMainExecutor.h:28
ml::MainExecutorT::operator()
void operator()(F f) const
Submit an function object of type 'void()' that should be executed within ML's main loop.
Definition
mlMainExecutor.h:53
mlBackgroundTaskManager.h
mlBackgroundTaskMessage.h
mlrange_cast
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
Definition
mlRangeCasts.h:332
mlTypeDefs.h
ml::MainExecutor
constexpr auto MainExecutor
Only necessary instance of this main executor.
Definition
mlMainExecutor.h:66
MeVis
Foundation
Sources
MLBackgroundTasks
mlMainExecutor.h
Generated by
1.10.0