YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
inline.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
yaclib/exe/executor.hpp
>
4
#include <
yaclib/fwd.hpp
>
5
6
namespace
yaclib
{
7
8
/**
9
* Get Inline executor singleton object.
10
*
11
* This executor immediately executes given Callable object in the same OS thread without any overhead.
12
* So it always return false from Submit, we only call Call, no submit
13
* \note This object is useful as safe default executor value. See example.
14
*
15
* \code
16
* auto task = [] {};
17
*
18
* // Without inline executor:
19
* IExecutorPtr executor = nullptr;
20
* if (...) {
21
* executor = MakeThreadPool(4);
22
* }
23
* if (executor) {
24
* executor->Submit(task);
25
* } else {
26
* a();
27
* }
28
*
29
* // With inline executor:
30
* IExecutorPtr executor = &MakeInline();
31
* if (...) {
32
* executor = MakeThreadPool(4);
33
* }
34
* executor->Submit(task);
35
* \endcode
36
*/
37
IExecutor&
MakeInline
()
noexcept
;
38
39
IExecutor&
MakeInline
(
StopTag
)
noexcept
;
40
41
}
// namespace yaclib
executor.hpp
fwd.hpp
yaclib
Definition
base_core.hpp:18
yaclib::MakeInline
IExecutor & MakeInline() noexcept
Get Inline executor singleton object.
Definition
inline.cpp:34
yaclib::MakeContract
Contract< V, E > MakeContract()
Creates related future and promise.
Definition
contract.hpp:25
include
yaclib
exe
inline.hpp
Generated by
1.9.8