MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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
()
noexcept
> _f;
34
35
public
:
36
template
<
typename
F>
void
setTask(
F
&& f)
37
{
38
_f = std::forward<F>(f);
39
}
40
41
void
execute()
override
42
{
43
_f();
44
}
45
};
46
47
public
:
50
template
<
typename
F>
void
operator()
(
F
f)
const
51
{
52
auto
message = std::make_unique<MainExecutorMessage>();
53
message->setTask(std::move(f));
54
BackgroundTaskManager::self().sendMessageToGUI(message.release());
55
}
56
};
57
63
constexpr
auto
MainExecutor
=
MainExecutorT
{};
64
65
ML_END_NAMESPACE
F
@ F
Definition
SoKeyGrabber.h:57
ml::BackgroundTaskMessage
The base class of all background messages.
Definition
mlBackgroundTaskMessage.h:41
ml::MainExecutorT
This class implements an executor that allows you to execute a task in the ML's main loop without imp...
Definition
mlMainExecutor.h:28
ml::MainExecutorT::operator()
void operator()(F f) const
Submit an function object of type 'void() noexcept' that should be executed within the ML's main loop...
Definition
mlMainExecutor.h:50
mlBackgroundTaskManager.h
mlBackgroundTaskMessage.h
mlrange_cast
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
Definition
mlRangeCasts.h:305
mlTypeDefs.h
ml::MainExecutor
constexpr auto MainExecutor
The only necessary instance of this main executor.
Definition
mlMainExecutor.h:63
MeVis
Foundation
Sources
MLBackgroundTasks
mlMainExecutor.h
Generated by
1.10.0