3#include <xrpl/basics/chrono.h>
4#include <xrpl/beast/core/List.h>
5#include <xrpl/server/detail/Door.h>
6#include <xrpl/server/detail/io_list.h>
8#include <boost/asio.hpp>
9#include <boost/asio/executor_work_guard.hpp>
10#include <boost/asio/io_context.hpp>
59template <
class Handler>
70 boost::asio::strand<boost::asio::io_context::executor_type>
strand_;
104 boost::asio::io_context&
118template <
class Handler>
121 boost::asio::io_context& io_context,
125 , io_context_(io_context)
126 , strand_(
boost::asio::make_strand(io_context_))
127 , work_(
std::in_place,
boost::asio::make_work_guard(io_context_))
131template <
class Handler>
140template <
class Handler>
145 Throw<std::logic_error>(
"ports() on closed Server");
146 ports_.reserve(ports.
size());
149 for (
auto const& port : ports)
151 ports_.push_back(port);
152 auto& internalPort = ports_.back();
153 if (
auto sp = ios_.emplace<
Door<Handler>>(handler_, io_context_, internalPort, j_))
157 auto ep = sp->get_endpoint();
158 if (!internalPort.port)
159 internalPort.port = ep.port();
160 eps.
emplace(port.name, std::move(ep));
168template <
class Handler>
174 handler_.onStopped(*
this);
178template <
class Handler>
182 return ios_.closed();
A generic endpoint for log messages.
std::vector< Port > ports_
boost::asio::io_context & get_io_context()
static int ceil_log2(unsigned long long x)
Endpoints ports(std::vector< Port > const &ports) override
Set the listening port settings.
void close() override
Close the server.
std::optional< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > work_
boost::asio::strand< boost::asio::io_context::executor_type > strand_
boost::asio::io_context & io_context_
ServerImpl(Handler &handler, boost::asio::io_context &io_context, beast::Journal journal)
std::array< std::size_t, 64 > hist_
std::vector< std::weak_ptr< Door< Handler > > > list_
beast::Journal journal() override
Returns the Journal associated with the server.
virtual void close()=0
Close the server.
virtual ~Server()=default
Destroy the server.
virtual beast::Journal journal()=0
Returns the Journal associated with the server.
virtual Endpoints ports(std::vector< Port > const &v)=0
Set the listening port settings.
Manages a set of objects performing asynchronous I/O.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.