YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
inline.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <yaclib/fwd.hpp>
5
6namespace 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 */
37IExecutor& MakeInline() noexcept;
38
39IExecutor& MakeInline(StopTag) noexcept;
40
41} // namespace yaclib
IExecutor & MakeInline() noexcept
Get Inline executor singleton object.
Definition inline.cpp:34
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25