1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #pragma once
- #include "rotor/supervisor_config.h"
- #include <boost/asio.hpp>
- #include <memory>
- #if defined(_MSC_VER)
- #pragma warning(push)
- #pragma warning(disable : 4251)
- #endif
- namespace rotor {
- namespace asio {
- struct supervisor_config_asio_t : public supervisor_config_t {
-
- using strand_t = boost::asio::io_context::strand;
-
- using strand_ptr_t = std::shared_ptr<strand_t>;
-
- strand_ptr_t strand;
-
- bool guard_context = false;
- using supervisor_config_t::supervisor_config_t;
- };
- template <typename Supervisor> struct supervisor_config_asio_builder_t : supervisor_config_builder_t<Supervisor> {
-
- using builder_t = typename Supervisor::template config_builder_t<Supervisor>;
-
- using parent_t = supervisor_config_builder_t<Supervisor>;
- using parent_t::parent_t;
-
- using strand_ptr_t = supervisor_config_asio_t::strand_ptr_t;
-
- constexpr static const std::uint32_t STRAND = 1 << 2;
-
- constexpr static const std::uint32_t requirements_mask = parent_t::requirements_mask | STRAND;
-
- builder_t &&strand(strand_ptr_t &strand) && {
- parent_t::config.strand = strand;
- parent_t::mask = (parent_t::mask & ~STRAND);
- return std::move(*static_cast<builder_t *>(this));
- }
-
- builder_t &&guard_context(bool value) && {
- parent_t::config.guard_context = value;
- return std::move(*static_cast<builder_t *>(this));
- }
- };
- }
- }
- #if defined(_MSC_VER)
- #pragma warning(pop)
- #endif
|