21 #ifndef G_NET_EVENT_LOOP__H
22 #define G_NET_EVENT_LOOP__H
57 G_EXCEPTION( Error ,
"failed to initialise the event loop" ) ;
58 G_EXCEPTION( NoInstance ,
"no event loop instance" ) ;
66 Running(
bool & bref ) : m_bref(bref) { m_bref = true ; }
90 virtual std::string
run() = 0 ;
94 virtual bool running()
const = 0 ;
97 virtual void quit( std::string reason ) = 0 ;
140 virtual std::string
report()
const = 0 ;
149 virtual void onException( std::exception & )
override ;
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().
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 onException(std::exception &) override
Override from ExceptionHandler that just rethrows the current exception.
virtual void dropRead(Descriptor fd)=0
Removes the given event source descriptor from the list of read sources.
A class that encapsulates a network socket file descriptor and an associated windows event handle...
virtual void addRead(Descriptor fd, EventHandler &, ExceptionHandler &)=0
Adds the given event source descriptor and associated handler to the read list.
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket events...
virtual void addWrite(Descriptor fd, EventHandler &, ExceptionHandler &)=0
Adds the given event source descriptor and associated handler to the write list.
static EventLoop * create()
A factory method which creates an instance of a derived class on the heap.
virtual void disarm(ExceptionHandler *)=0
Used to prevent the given interface from being used, typically called from the ExceptionHandler destr...
virtual bool running() const =0
Returns true if called from within run().
virtual std::string run()=0
Runs the main event loop.
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 dropOther(Descriptor fd)=0
Removes the given event source descriptor from the list of exception sources.
virtual void dropWrite(Descriptor fd)=0
Removes the given event source descriptor from the list of write sources.
virtual void addOther(Descriptor fd, EventHandler &, ExceptionHandler &)=0
Adds the given event source descriptor and associated handler to the exception list.
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).