1#ifndef XRPL_SERVER_SERVERIMPL_H_INCLUDED
2#define XRPL_SERVER_SERVERIMPL_H_INCLUDED
4#include <xrpl/basics/chrono.h>
5#include <xrpl/beast/core/List.h>
6#include <xrpl/server/detail/Door.h>
7#include <xrpl/server/detail/io_list.h>
9#include <boost/asio.hpp>
10#include <boost/asio/executor_work_guard.hpp>
11#include <boost/asio/io_context.hpp>
61template <
class Handler>
72 boost::asio::strand<boost::asio::io_context::executor_type>
strand_;
74 boost::asio::io_context::executor_type>>
88 boost::asio::io_context& io_context,
111 boost::asio::io_context&
125template <
class Handler>
128 boost::asio::io_context& io_context,
132 , io_context_(io_context)
133 , strand_(
boost::asio::make_strand(io_context_))
134 , work_(
std::in_place,
boost::asio::make_work_guard(io_context_))
138template <
class Handler>
147template <
class Handler>
152 Throw<std::logic_error>(
"ports() on closed Server");
153 ports_.reserve(ports.
size());
156 for (
auto const& port : ports)
158 ports_.push_back(port);
159 auto& internalPort = ports_.back();
161 handler_, io_context_, internalPort, j_))
165 auto ep = sp->get_endpoint();
166 if (!internalPort.port)
167 internalPort.port = ep.port();
168 eps.
emplace(port.name, std::move(ep));
176template <
class Handler>
182 handler_.onStopped(*
this);
186template <
class Handler>
190 return ios_.closed();
A generic endpoint for log messages.
std::vector< std::weak_ptr< Door< Handler > > > list_
std::vector< Port > ports_
boost::asio::strand< boost::asio::io_context::executor_type > strand_
void close() override
Close the server.
std::array< std::size_t, 64 > hist_
boost::asio::io_context & get_io_context()
beast::Journal journal() override
Returns the Journal associated with the server.
std::optional< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > work_
static int ceil_log2(unsigned long long x)
boost::asio::io_context & io_context_
Endpoints ports(std::vector< Port > const &ports) override
Set the listening port settings.
ServerImpl(Handler &handler, boost::asio::io_context &io_context, beast::Journal journal)
virtual void close()=0
Close the server.
virtual Endpoints ports(std::vector< Port > const &v)=0
Set the listening port settings.
virtual ~Server()=default
Destroy the server.
virtual beast::Journal journal()=0
Returns the Journal associated with the server.
Manages a set of objects performing asynchronous I/O.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.