21 #ifndef G_EVENT_LOOP_H
22 #define G_EVENT_LOOP_H
54 G_EXCEPTION( NoInstance ,
"no event loop instance" ) ;
77 virtual bool init() = 0 ;
80 virtual std::string
run() = 0 ;
84 virtual bool running()
const = 0 ;
87 virtual void quit( std::string reason ) = 0 ;
virtual bool init()=0
Initialises the object.
virtual void addWrite(Descriptor fd, EventHandler &handler)=0
Adds the given event source descriptor and associated handler to the write list.
An abstract base class for a singleton that keeps track of open sockets and their associated handlers...
virtual void dropRead(Descriptor fd)=0
Removes the given event source descriptor from the list of read sources.
A network file descriptor.
virtual void dropException(Descriptor fd)=0
Removes the given event source descriptor from the list of exception sources.
virtual void addRead(Descriptor fd, EventHandler &handler)=0
Adds the given event source descriptor and associated handler to the read list.
virtual bool running() const =0
Returns true if called from within run().
virtual std::string run()=0
Runs the main event loop.
virtual void setTimeout(G::DateTime::EpochTime t, bool &empty_implementation_hint)=0
Used by GNet::TimerList.
virtual void addException(Descriptor fd, EventHandler &handler)=0
Adds the given event source descriptor and associated handler to the exception list.
A base class for classes that handle asynchronous socket events.
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
static EventLoop * create()
A factory method which creates an instance of a derived class on the heap.
static bool exists()
Returns true if an instance exists.
virtual ~EventLoop()
Destructor.
virtual void dropWrite(Descriptor fd)=0
Removes the given event source descriptor from the list of write sources.
static EventLoop & instance()
Returns a reference to an instance of the class, if any.
virtual void quit(std::string reason)=0
Causes run() to return (once the call stack has unwound).