63 typedef std::unique_ptr<ConnectionManager, Destructor>
UniquePtr;
70 template<
typename...
Args>
79 std::chrono::milliseconds
timeout,
91 bool timeout =
false);
97 std::chrono::milliseconds timeout);
103 std::chrono::milliseconds timeout);
140 template <
typename F>
143 while ( it !=
conns_.end()) {
154 CHECK(timeout >= std::chrono::milliseconds(0));
177 NOTIFY_PENDING_SHUTDOWN = 1,
179 NOTIFY_PENDING_SHUTDOWN_COMPLETE = 2,
183 CLOSE_WHEN_IDLE_COMPLETE = 4,
199 return shutdownState_;
203 shutdownState_ =
state;
206 void startDrainPartial(
double pct, std::chrono::milliseconds idleGrace);
207 void startDrainAll(std::chrono::milliseconds idleGrace);
210 VLOG(3) <<
"Draining more conns from loop callback";
215 VLOG(3) <<
"Idle grace expired";
223 void startDrain(std::chrono::milliseconds idleGrace);
227 return manager_.conns_.begin();
229 auto it = manager_.conns_.begin();
230 const auto conns_size = manager_.conns_.size();
231 const auto numToDrain =
232 std::max<size_t>(0, std::min<size_t>(conns_size, conns_size * pct_));
233 std::advance(it, conns_size - numToDrain);
size_t dropIdleConnections(size_t num)
virtual void onEmpty(const ConnectionManager &cm)=0
void iterateConns(F func)
void addConnection(ManagedConnection *connection, bool timeout=false)
void timeoutExpired() noexceptoverride
ConnectionManager & operator=(ConnectionManager &)=delete
void stopDrainingForShutdown()
ConnectionIterator drainStartIterator() const
folly::EventBase * eventBase_
ConnectionManager(folly::EventBase *eventBase, std::chrono::milliseconds timeout, Callback *callback=nullptr)
void dropConnections(double pct)
std::unique_ptr< ConnectionManager, Destructor > UniquePtr
ShutdownState getShutdownState()
virtual void onConnectionRemoved(const ManagedConnection *conn)=0
std::chrono::milliseconds getDefaultTimeout() const
ConnectionIterator drainIterator_
size_t getNumConnections() const
folly::SafeIntrusiveListHook listHook_
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
void removeConnection(ManagedConnection *connection)
void onActivated(ManagedConnection &conn) override
void initiateGracefulShutdown(std::chrono::milliseconds idleGrace)
folly::CountedIntrusiveList< ManagedConnection,&ManagedConnection::listHook_ >::iterator ConnectionIterator
void dropAllConnections()
~ConnectionManager() override=default
void onDeactivated(ManagedConnection &conn) override
void scheduleTimeout(ManagedConnection *const connection, std::chrono::milliseconds timeout)
static UniquePtr makeUnique(Args &&...args)
void drainAllConnections()
ConnectionIterator idleIterator_
void drainConnections(double pct, std::chrono::milliseconds idleGrace)
ConnectionManager & manager_
std::chrono::milliseconds timeout_
DrainHelper(ConnectionManager &manager)
bool notifyPendingShutdown_
void runLoopCallback() noexceptoverride
folly::CountedIntrusiveList< ManagedConnection,&ManagedConnection::listHook_ > conns_
virtual void onConnectionAdded(const ManagedConnection *conn)=0
void setLoweredIdleTimeout(std::chrono::milliseconds timeout)
std::chrono::milliseconds idleConnEarlyDropThreshold_
void setShutdownState(ShutdownState state)
void idleGracefulTimeoutExpired()
boost::intrusive::list< T, boost::intrusive::member_hook< T, SafeIntrusiveListHook, PtrToMember >, boost::intrusive::constant_time_size< true >> CountedIntrusiveList
virtual ~Callback()=default