37 G_DEBUG(
"GNet::EventHandler::readEvent: no override" ) ;
42 G_DEBUG(
"GNet::EventHandler::writeEvent: no override" ) ;
61 return m_map.begin() ;
71 return m_map.find(fd) != m_map.end() ;
76 Map::iterator p = m_map.find( fd ) ;
77 return p != m_map.end() ? (*p).second : NULL ;
83 G_DEBUG(
"GNet::EventHandlerList::add: " << m_type <<
"-list: " <<
"adding " << fd ) ;
90 Map::iterator p = m_map.find( fd ) ;
91 if( p != m_map.end() )
93 G_DEBUG(
"GNet::EventHandlerList::remove: " << m_type <<
"-list: " <<
"removing " << fd ) ;
97 m_has_garbage = true ;
115 if( m_lock == 0U && m_has_garbage )
119 void GNet::EventHandlerList::collectGarbage()
121 const Map::iterator end = m_map.end() ;
122 for( Map::iterator p = m_map.begin() ; p != end ; )
124 Map::iterator test = p++ ;
125 if( (*test).second == NULL )
126 m_map.erase( test ) ;
128 m_has_garbage = false ;
Iterator begin() const
Returns a forward iterator.
virtual void readEvent()
Called for a read event.
A network file descriptor.
void lock()
Called at the start of an iteration which might change the list.
virtual void writeEvent()
Called for a write event.
Map::const_iterator Iterator
bool contains(Descriptor fd) const
Returns true if the list contains the given file-descriptor.
A base class for classes that handle asynchronous socket events.
void add(Descriptor fd, EventHandler *handler)
Adds a file-descriptor/handler pair to the list.
void unlock()
Called at the end of an iteration.
void remove(Descriptor fd)
Removes a file-descriptor from the list.
Iterator end() const
Returns an end iterator.
A general-purpose exception class derived from std::exception and containing a std::string.
EventHandlerList(const std::string &type)
Constructor.
EventHandler * find(Descriptor fd)
Finds the handler associated with the given file descriptor.
virtual ~EventHandler()
Destructor.
virtual void exceptionEvent()
Called for an exception event.