32 #define HT_DISABLE_LOG_DEBUG 1
48 IdHandlerMap::iterator iter = m_id_map.find(
id);
53 node->expire = expire;
56 node->next = node->prev = 0;
57 m_head = m_tail = node;
61 node->next->prev = node;
74 IdHandlerMap::iterator iter = m_id_map.find(
id);
76 if (iter == m_id_map.end()) {
77 HT_DEBUGF(
"ID %d not found in request cache",
id);
107 bool handler_removed =
false;
108 while (m_head && !handler_removed && m_head->expire <= now) {
110 IdHandlerMap::iterator iter = m_id_map.find(m_head->id);
111 assert (iter != m_id_map.end());
114 m_head = m_head->
prev;
120 m_id_map.erase(iter);
122 if (node->handler != 0) {
123 handlerp = node->handler;
125 handler_removed =
true;
131 *next_timeout = m_head->expire;
135 return handler_removed;
141 for (
CacheNode *node = m_tail; node != 0; node = node->
next) {
142 if (node->handler == handler) {
145 HT_DEBUGF(
"Purging request id %d", node->id);
void purge_requests(IOHandler *handler, int32_t error)
Purges all requests assocated with handler.
std::string String
A String is simply a typedef to std::string.
chrono::time_point< fast_clock > time_point
Abstract base class for application dispatch handlers registered with AsyncComm.
CacheNode * next
Doubly-linked list pointers.
InetAddr get_address()
Gets the handler socket address.
Internal cache node structure.
bool remove(uint32_t id, DispatchHandler *&handler)
Removes a request from the cache.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
const String & get_proxy()
Gets the proxy name for this connection.
Logging routines and macros.
Compatibility Macros for C/C++.
Base class for socket descriptor I/O handlers.
Declarations for RequestCache.
Declarations for IOHandlerData.
void insert(uint32_t id, IOHandler *handler, DispatchHandler *dh, ClockT::time_point &expire)
Inserts pending request callback handler into cache.
#define HT_DEBUGF(msg,...)
void deliver_event(EventPtr &event, DispatchHandler *dh=0)
Convenience method for delivering event to application.
DispatchHandler * dh
Callback handler to which MESSAGE, TIMEOUT, ERROR, and DISCONNECT events are delivered.
bool get_next_timeout(ClockT::time_point &now, IOHandler *&handlerp, DispatchHandler *&dh, ClockT::time_point *next_timeout)
Removes next request that has timed out.