21 #ifndef G_EVENT_LOOP_H
22 #define G_EVENT_LOOP_H
55 G_EXCEPTION( Error ,
"failed to initialise the event loop" ) ;
56 G_EXCEPTION( NoInstance ,
"no event loop instance" ) ;
64 Running(
bool & bref ) : m_bref(bref) { m_bref = true ; }
88 virtual std::string
run() = 0 ;
92 virtual bool running()
const = 0 ;
95 virtual void quit( std::string reason ) = 0 ;
138 virtual std::string
report()
const = 0 ;
A subsecond-resolution timestamp based on a time_t.
virtual void setTimeout(G::EpochTime t)=0
Used by GNet::TimerList.
static void stop(const G::SignalSafe &)
Calls quit() on instance().
virtual void addWrite(Descriptor fd, EventHandler &handler)=0
Adds the given event source descriptor and associated handler to the write list.
An empty structure that is used to indicate a signal-safe, reentrant implementation.
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 class that encapsulates a network file descriptor and hides knowledge of its o/s-spefific error val...
virtual void dropException(Descriptor fd)=0
Removes the given event source descriptor from the list of exception sources.
static EventLoop * create()
A factory method which creates an instance of a derived class on the heap.
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 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 events from the event loop.
RAII class that sets a boolean, for implementations of run()/running().
virtual std::string report() const =0
Returns a line of text reporting the status of the event loop.
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).