Bitcoin Core  27.99.0
P2P Digital Currency
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HTTPRequestTracker Class Reference

Helps keep track of open evhttp_connections with active evhttp_requests More...

Collaboration diagram for HTTPRequestTracker:
[legend]

Public Member Functions

void AddRequest (evhttp_request *req) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
 Increase request counter for the associated connection by 1. More...
 
void RemoveRequest (evhttp_request *req) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
 Decrease request counter for the associated connection by 1, remove connection if counter is 0. More...
 
void RemoveConnection (const evhttp_connection *conn) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
 Remove a connection entirely. More...
 
size_t CountActiveConnections () const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
 
void WaitUntilEmpty () const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
 Wait until there are no more connections with active requests in the tracker. More...
 

Private Member Functions

std::unordered_map< const evhttp_connection *, size_t > m_tracker GUARDED_BY (m_mutex)
 For each connection, keep a counter of how many requests are open. More...
 
void RemoveConnectionInternal (const decltype(m_tracker)::iterator it) EXCLUSIVE_LOCKS_REQUIRED(m_mutex)
 

Private Attributes

Mutex m_mutex
 
std::condition_variable m_cv
 

Detailed Description

Helps keep track of open evhttp_connections with active evhttp_requests

Definition at line 158 of file httpserver.cpp.

Member Function Documentation

◆ AddRequest()

void HTTPRequestTracker::AddRequest ( evhttp_request *  req)
inline

Increase request counter for the associated connection by 1.

Definition at line 173 of file httpserver.cpp.

Here is the caller graph for this function:

◆ CountActiveConnections()

size_t HTTPRequestTracker::CountActiveConnections ( ) const
inline

Definition at line 195 of file httpserver.cpp.

Here is the caller graph for this function:

◆ GUARDED_BY()

std::unordered_map<const evhttp_connection*, size_t> m_tracker HTTPRequestTracker::GUARDED_BY ( m_mutex  )
private

For each connection, keep a counter of how many requests are open.

◆ RemoveConnection()

void HTTPRequestTracker::RemoveConnection ( const evhttp_connection *  conn)
inline

Remove a connection entirely.

Definition at line 189 of file httpserver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveConnectionInternal()

void HTTPRequestTracker::RemoveConnectionInternal ( const decltype(m_tracker)::iterator  it)
inlineprivate

Definition at line 166 of file httpserver.cpp.

Here is the caller graph for this function:

◆ RemoveRequest()

void HTTPRequestTracker::RemoveRequest ( evhttp_request *  req)
inline

Decrease request counter for the associated connection by 1, remove connection if counter is 0.

Definition at line 179 of file httpserver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WaitUntilEmpty()

void HTTPRequestTracker::WaitUntilEmpty ( ) const
inline

Wait until there are no more connections with active requests in the tracker.

Definition at line 200 of file httpserver.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ m_cv

std::condition_variable HTTPRequestTracker::m_cv
mutableprivate

Definition at line 162 of file httpserver.cpp.

◆ m_mutex

Mutex HTTPRequestTracker::m_mutex
mutableprivate

Definition at line 161 of file httpserver.cpp.


The documentation for this class was generated from the following file: