rotor
Event loop friendly C++ actor micro-framework
 
Loading...
Searching...
No Matches
supervisor_config_ev.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 <ev.h>
11
12namespace rotor {
13namespace ev {
14
21 struct ev_loop *loop;
22
24 bool loop_ownership = false;
25
26 using supervisor_config_t::supervisor_config_t;
27};
28
30template <typename Supervisor> struct supervisor_config_ev_builder_t : supervisor_config_builder_t<Supervisor> {
32 using builder_t = typename Supervisor::template config_builder_t<Supervisor>;
33
37
39 constexpr static const std::uint32_t LOOP = 1 << 2;
40
42 constexpr static const std::uint32_t LOOP_OWNERSHIP = 1 << 3;
43
45 constexpr static const std::uint32_t requirements_mask = parent_t::requirements_mask | LOOP | LOOP_OWNERSHIP;
46
48 builder_t &&loop(struct ev_loop *loop) && {
51 return std::move(*static_cast<builder_t *>(this));
52 }
53
55 builder_t &&loop_ownership(bool value) && {
56 parent_t::config.loop_ownership = value;
57 parent_t::mask = (parent_t::mask & ~LOOP_OWNERSHIP);
58 return std::move(*static_cast<builder_t *>(this));
59 }
60};
61
62} // namespace ev
63} // namespace rotor
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 ev config builder.
Definition supervisor_config_ev.h:30
builder_t && loop(struct ev_loop *loop) &&
sets loop
Definition supervisor_config_ev.h:48
static constexpr const std::uint32_t LOOP
bit mask for loop validation
Definition supervisor_config_ev.h:39
static constexpr const std::uint32_t LOOP_OWNERSHIP
bit mask for loop ownership validation
Definition supervisor_config_ev.h:42
builder_t && loop_ownership(bool value) &&
instructs to take ownership on the loop (aka be destroyed by supervisor)
Definition supervisor_config_ev.h:55
static constexpr const std::uint32_t requirements_mask
bit mask for all required fields
Definition supervisor_config_ev.h:45
typename Supervisor::template config_builder_t< Supervisor > builder_t
final builder class
Definition supervisor_config_ev.h:32
libev supervisor config, which holds a pointer to the ev event loop and a loop ownership flag
Definition supervisor_config_ev.h:19
struct ev_loop * loop
a pointer to EV event loop
Definition supervisor_config_ev.h:21
bool loop_ownership
whether loop should be destroyed by supervisor
Definition supervisor_config_ev.h:24
CRTP supervisor config builder.
Definition supervisor_config.h:72
base supervisor config, which holds shutdown timeout value
Definition supervisor_config.h:23