rotor
Event loop friendly C++ actor micro-framework
 
Loading...
Searching...
No Matches
supervisor_config_asio.h
1#pragma once
2
3//
4// Copyright (c) 2019-2022 Ivan Baidakou (basiliscos) (the dot dmol at gmail dot com)
5//
6// Distributed under the MIT Software License
7//
8
9#include "rotor/supervisor_config.h"
10#include <boost/asio.hpp>
11#include <memory>
12
13#if defined(_MSC_VER)
14#pragma warning(push)
15#pragma warning(disable : 4251)
16#endif
17
18namespace rotor {
19namespace asio {
20
25 using strand_t = boost::asio::io_context::strand;
26
28 using strand_ptr_t = std::shared_ptr<strand_t>;
29
32
34 bool guard_context = false;
35
36 using supervisor_config_t::supervisor_config_t;
37};
38
40template <typename Supervisor> struct supervisor_config_asio_builder_t : supervisor_config_builder_t<Supervisor> {
42 using builder_t = typename Supervisor::template config_builder_t<Supervisor>;
43
47
50
52 constexpr static const std::uint32_t STRAND = 1 << 2;
53
55 constexpr static const std::uint32_t requirements_mask = parent_t::requirements_mask | STRAND;
56
59 parent_t::config.strand = strand;
60 parent_t::mask = (parent_t::mask & ~STRAND);
61 return std::move(*static_cast<builder_t *>(this));
62 }
63
65 builder_t &&guard_context(bool value) && {
66 parent_t::config.guard_context = value;
67 return std::move(*static_cast<builder_t *>(this));
68 }
69};
70
71} // namespace asio
72} // namespace rotor
73
74#if defined(_MSC_VER)
75#pragma warning(pop)
76#endif
Basic namespace for all rotor functionalities.
Definition rotor.hpp:21
config_t config
the currently build config
Definition actor_config.h:128
static constexpr const std::uint32_t requirements_mask
bit mask for all required fields
Definition actor_config.h:116
std::uint32_t mask
required fields mask (used for validation)
Definition actor_config.h:131
CRTP supervisor asio config builder.
Definition supervisor_config_asio.h:40
typename Supervisor::template config_builder_t< Supervisor > builder_t
final builder class
Definition supervisor_config_asio.h:42
static constexpr const std::uint32_t STRAND
bit mask for strand validation
Definition supervisor_config_asio.h:52
builder_t && strand(strand_ptr_t &strand) &&
strand setter
Definition supervisor_config_asio.h:58
builder_t && guard_context(bool value) &&
instructs to take ownership of the io_context
Definition supervisor_config_asio.h:65
supervisor_config_asio_t::strand_ptr_t strand_ptr_t
alias for strand smart pointer
Definition supervisor_config_asio.h:49
static constexpr const std::uint32_t requirements_mask
bit mask for all required fields
Definition supervisor_config_asio.h:55
boost::asio supervisor config, which holds pointer to strand
Definition supervisor_config_asio.h:23
strand_ptr_t strand
boost::asio execution strand (shared pointer)
Definition supervisor_config_asio.h:31
bool guard_context
should supervisor take ownership on the io_context
Definition supervisor_config_asio.h:34
std::shared_ptr< strand_t > strand_ptr_t
type for strand shared pointer
Definition supervisor_config_asio.h:28
boost::asio::io_context::strand strand_t
alias for boost::asio strand type
Definition supervisor_config_asio.h:25
CRTP supervisor config builder.
Definition supervisor_config.h:72
base supervisor config, which holds shutdown timeout value
Definition supervisor_config.h:23