userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
run_standalone.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/engine/run_standalone.hpp
4
/// @brief @copybrief engine::RunStandalone
5
6
#
include
<
cstddef
>
7
#
include
<
string
>
8
9
#
include
<
userver
/
engine
/
deadlock_detector_config
.
hpp
>
10
#
include
<
userver
/
engine
/
task_queue_type
.
hpp
>
11
#
include
<
userver
/
utils
/
function_ref
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
engine {
16
17
/// @brief A lightweight TaskProcessor config for engine::RunStandalone
18
struct
TaskProcessorPoolsConfig
final
{
19
std::size_t initial_coro_pool_size = 10;
20
std::size_t max_coro_pool_size = 100;
21
std::size_t coro_stack_size = 256 * 1024ULL;
22
std::size_t ev_threads_num = 1;
23
std::string ev_thread_name =
"ev"
;
24
bool
ev_default_loop_disabled =
false
;
25
bool
is_stack_usage_monitor_enabled =
true
;
26
TaskQueueType
queue_type{
TaskQueueType
::kGlobalTaskQueue};
27
DeadlockDetector
deadlock_detector{
DeadlockDetector
::kOff};
28
};
29
30
/// @brief Runs a payload in a temporary coroutine engine instance.
31
///
32
/// Creates a TaskProcessor with specified parameters, executes the payload
33
/// in an Async and exits. Mainly designated for async code unit testing.
34
///
35
/// @warning This function must not be used while another engine instance is
36
/// running.
37
///
38
/// @param payload Code to be run in a Task
39
void
RunStandalone
(
utils
::function_ref<
void
()> payload);
40
41
/// @overload
42
///
43
/// @param worker_threads Engine thread pool size, 1 by default
44
/// @param payload Code to be run in a Task
45
void
RunStandalone
(std::size_t worker_threads,
utils
::function_ref<
void
()> payload);
46
47
/// @overload
48
///
49
/// @param worker_threads Engine thread pool size, 1 by default
50
/// @param config A lightweight TaskProcessor config
51
/// @param payload Code to be run in a Task
52
void
RunStandalone
(
53
std::size_t worker_threads,
54
const
TaskProcessorPoolsConfig& config,
55
utils
::function_ref<
void
()> payload
56
);
57
58
}
// namespace engine
59
60
USERVER_NAMESPACE_END
userver
engine
run_standalone.hpp
Generated on
for userver by
Doxygen
1.17.0