21 # include <sys/resource.h> 78 const std::string& name_ =
"<unknown>");
183 Fd2Eh_Map_Type& fdSet_,
Mask that includes all events.
std::map< u_int, EventHandler * > Fd2Eh_Map_Type
no cloning
handler_t m_maxfd_plus1
Max file descriptor number (in all sets) plus 1.
bool registerIOHandler(EventHandler *eh_, handler_t fd_, EventType et_=RWE_EVENTS)
Register I/O Event handler with Reactor.
void adjust_maxfdp1(handler_t fd_)
Adjust maxfdp1 in a portable way (win32 ignores maxfd alltogether).
Reactor & operator=(const Reactor &)
no cloning
Bundles file descriptor mask sets to be used with select().
bool removeHandler(EventHandler *eh_, EventType et_=ALL_EVENTS)
Remove Event handler from reactor for either all I/O events or timeout event or both.
bool removeTimerHandler(TimerId id_)
Remove Timer event from the queue.
bool handleError(void)
Handle error in select(2) loop appropriately.
MaskSet m_waitSet
Handlers to wait for event on.
Fd2Eh_Map_Type m_writeSet
Event handlers awaiting on WRITE_EVENT.
READ_EVENT | WRITE_EVENT | EXCEPT_EVENT.
bool removeIOHandler(handler_t fd_)
Remove IO Event handler from reactor.
TimerCountdown class keep the track of the elapsed time.
Singleton template class allows to turn any new or existing class T into Singleton Pattern...
Fd2Eh_Map_Type m_readSet
Event handlers awaiting on READ_EVENT.
void stopReactor(void)
Stop Reactor's activity.
An abstract interface for handling I/O events, timers, and such.
int(EventHandler::* EH_IO_Callback)(int)
A type for the pointer to I/O-related callback member function of class EventHandler.
bool m_active
Flag that indicates whether Reactor is active or had been stopped.
void deactivate(void)
Deactivate Reactor.
void waitForEvents(void)
Main waiting loop that blocks indefinitely processing events.
unsigned long TimerId
Timer Id is used in handle_timeout() calls.
TimerId registerTimerHandler(EventHandler *eh_, const TimeVal &tv_, const std::string &name_="<unknown>")
Register Timer Event handler with Reactor.
Fd2Eh_Map_Type::iterator Fd2Eh_Map_Iter
bool checkFDs(void)
Check mask for bad file descriptors.
TimerQueue m_tqueue
The queue of Timers.
TimerQueue class represents the queue of Timers that application can install for Reactor to dispatch...
void dispatchHandler(FdSet &mask_, Fd2Eh_Map_Type &fdSet_, EH_IO_Callback callback_)
Call handler's callback and, if callback returns negative value, remove it from the Reactor...
void calculateTimeout(TimeVal *&howlong_, TimeVal *maxwait_)
Calculate closest timeout.
bool dispatch(int minimum_)
Notify all EventHandlers registered on respecful events occured.
Fd2Eh_Map_Type m_exceptSet
Event handlers awaiting on EXCEPT_EVENT.
EventType
EventType defines events types that Reactor understands.
MaskSet m_readySet
Handlers that are ready for processing.
int isAnyReady(void)
Return number of file descriptors ready accross all sets.
int m_fd_setsize
Max number of open files per process.