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>
122 , io_context_(io_context)
123 , strand_(
boost::asio::make_strand(io_context_))
124 , work_(
std::in_place,
boost::asio::make_work_guard(io_context_))
128template <
class Handler>
137template <
class Handler>
142 Throw<std::logic_error>(
"ports() on closed Server");
143 ports_.reserve(ports.
size());
146 for (
auto const& port : ports)
148 ports_.push_back(port);
149 auto& internalPort = ports_.back();
150 if (
auto sp = ios_.emplace<
Door<Handler>>(handler_, io_context_, internalPort, j_))
154 auto ep = sp->get_endpoint();
155 if (!internalPort.port)
156 internalPort.port = ep.port();
157 eps.
emplace(port.name, std::move(ep));
165template <
class Handler>
171 handler_.onStopped(*
this);
175template <
class Handler>
179 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.