25namespace connection_count_limits
87 std::size_t index )
noexcept = 0;
100 std::size_t index )
noexcept = 0;
114template<
typename Mutex_Type >
191 std::lock_guard< Mutex_Type > lock{
m_lock };
209 std::lock_guard< Mutex_Type > lock{
m_lock };
218 return pending_index;
224 if( index_to_activate )
226 m_acceptor->schedule_next_accept_attempt( *index_to_activate );
240 const bool accept_now = [
this, index]() ->
bool {
241 std::lock_guard< Mutex_Type > lock{
m_lock };
309template<
typename Strand >
328 using base_t::base_t;
347 using base_t::base_t;
373template<
typename Count_Manager >
383 m_manager->increment_parallel_connections();
389 m_manager->decrement_parallel_connections();
401 swap( a.m_manager, b.m_manager );
408 other.m_manager =
nullptr;
457template<
typename Traits >
462 Traits::use_connection_count_limiter,
464 typename Traits::strand_t >,
Template class for connection count limiter for the case when connection count limit is actually used...
connection_lifetime_monitor_t(not_null_pointer_t< noop_connection_count_limiter_t >) noexcept
Helper type for controlling the lifetime of the connection.
connection_lifetime_monitor_t & operator=(connection_lifetime_monitor_t &&other) noexcept
~connection_lifetime_monitor_t()
friend void swap(connection_lifetime_monitor_t &a, connection_lifetime_monitor_t &b) noexcept
connection_lifetime_monitor_t(connection_lifetime_monitor_t &&other) noexcept
connection_lifetime_monitor_t & operator=(const connection_lifetime_monitor_t &)=delete
connection_lifetime_monitor_t(const connection_lifetime_monitor_t &)=delete
not_null_pointer_t< Count_Manager > m_manager
connection_lifetime_monitor_t(not_null_pointer_t< Count_Manager > manager) noexcept
An interface of acceptor to be used by connection count limiters.
virtual void schedule_next_accept_attempt(std::size_t index) noexcept=0
virtual void call_accept_now(std::size_t index) noexcept=0
Actual implementation of connection count limiter.
std::vector< std::size_t > m_pending_indexes
The storage for holding pending socket's slots.
std::size_t m_active_accepts
The counter of active accept() operations.
Mutex_Type m_lock
Lock object to be used.
actual_limiter_t(actual_limiter_t &&)=delete
const std::size_t m_max_parallel_connections
The limit for parallel connections.
RESTINIO_NODISCARD bool has_free_slots() const noexcept
std::size_t m_connections
The counter of active connections.
actual_limiter_t(not_null_pointer_t< acceptor_callback_iface_t > acceptor, max_parallel_connections_t max_parallel_connections, max_active_accepts_t max_pending_indexes)
actual_limiter_t(const actual_limiter_t &)=delete
void decrement_parallel_connections() noexcept
void increment_parallel_connections() noexcept
not_null_pointer_t< acceptor_callback_iface_t > m_acceptor
Mandatory pointer to the acceptor connected with this limiter.
void accept_next(std::size_t index) noexcept
An implementation of connection count limiter for the case when connection count is not limited.
noop_connection_count_limiter_t(not_null_pointer_t< connection_count_limits::impl::acceptor_callback_iface_t > acceptor, max_parallel_connections_t, max_active_accepts_t)
void accept_next(std::size_t index) noexcept
void increment_parallel_connections() noexcept
void decrement_parallel_connections() noexcept
not_null_pointer_t< connection_count_limits::impl::acceptor_callback_iface_t > m_acceptor
Helper template for defining tagged scalar types.
RESTINIO_NODISCARD constexpr Scalar value() const noexcept
#define RESTINIO_NODISCARD
Typedefs for default strands.
const nullopt_t nullopt((nullopt_t::init()))
void swap(optional< T > &x, optional< T > &y)
asio_ns::strand< default_asio_executor > default_strand_t
A typedef for the default strand type.
T * not_null_pointer_t
Type for pointer that is not null by design.
default_asio_executor noop_strand_t
A typedef for no-op strand type.
Definition of null_mutex.
A kind of metafunction that deduces actual types related to connection count limiter in the dependecy...
typename std::conditional< Traits::use_connection_count_limiter, connection_count_limits::connection_count_limiter_t< typename Traits::strand_t >, connection_count_limits::noop_connection_count_limiter_t >::type limiter_t
Helper template for defining tagged scalar types.