21 #ifndef G_EVENT_HANDLER_LIST__H
22 #define G_EVENT_HANDLER_LIST__H
33 class EventHandlerList ;
71 Value() : second(
nullptr) , third(
nullptr) {}
73 explicit Value(
Descriptor fd ) : first(fd) , second(
nullptr) , third(
nullptr) {}
78 Iterator(
const std::vector<Value> & ,
bool ) ;
79 Iterator( std::vector<Value>::const_iterator , std::vector<Value>::const_iterator ) ;
81 const Value & operator*()
const ;
82 bool operator==(
const Iterator & )
const ;
83 bool operator!=(
const Iterator & )
const ;
88 void raiseEvent(
void (
EventHandler::*method)(EventHandler::Reason) , EventHandler::Reason ) ;
89 std::vector<Value>::const_iterator m_p ;
90 std::vector<Value>::const_iterator m_end ;
140 typedef std::vector<Value> List ;
144 static bool disable( List & list ,
Descriptor fd ) ;
145 static bool remove( List & list ,
Descriptor fd ) ;
147 void commitPending() ;
148 void collectGarbage() ;
153 List m_pending_list ;
154 unsigned int m_lock ;
171 GNet::EventHandlerList::Iterator::Iterator( std::vector<Value>::const_iterator p , std::vector<Value>::const_iterator end ) :
178 GNet::EventHandlerList::Iterator::Iterator(
const std::vector<Value> & v ,
bool end ) :
179 m_p(end?v.end():v.begin()) ,
182 while( m_p != m_end && (*m_p).second ==
nullptr )
190 while( m_p != m_end && (*m_p).second ==
nullptr )
204 return (*m_p).first ;
210 return (*m_p).second ;
216 return (*m_p).third ;
220 bool GNet::EventHandlerList::Iterator::operator==(
const Iterator & other )
const
222 return m_p == other.m_p ;
226 bool GNet::EventHandlerList::Iterator::operator!=(
const Iterator & other )
const
228 return !(*
this == other) ;
Iterator find(Descriptor fd) const
Finds an entry in the list.
Iterator begin() const
Returns a forward iterator. Use lock() before iterating.
A class that encapsulates a network socket file descriptor and an associated windows event handle...
void disarm(ExceptionHandler *)
Resets any matching ExceptionHandler pointers.
void lock()
To be called at the start of an begin()/end() iteration if the list might change during the iteration...
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket events...
bool unlock()
Called at the end of a begin()/end() iteration to match a call to lock().
A raii class to lock and unlock GNet::EventHandlerList.
bool contains(Descriptor fd) const
Returns true if the list, taking account of any pending changes, contains the given descriptor...
A base class for classes that handle asynchronous events from the event loop.
void add(Descriptor fd, EventHandler *handler, ExceptionHandler *)
Adds a file-descriptor/handler tuple to the list.
Iterator end() const
Returns an end iterator.
A tuple for GNet::EventHandlerList.
An iterator for GNet::EventHandlerList.
EventHandlerList(const std::string &type)
Constructor.
A class that maps from a file descriptor to an event handler, used in the implemention of classes der...