21#ifndef G_NET_EVENT_LOOP_H
22#define G_NET_EVENT_LOOP_H
55 G_EXCEPTION( Error ,
"failed to initialise the event loop" ) ;
56 G_EXCEPTION( NoInstance ,
"no event loop instance" ) ;
57 G_EXCEPTION( Overflow ,
"event loop overflow" ) ;
64 static std::unique_ptr<EventLoop>
create() ;
86 virtual std::string
run() = 0 ;
93 virtual void quit(
const std::string & reason ) = 0 ;
139 void operator=(
const EventLoop & ) = delete ;
140 void operator=(
EventLoop && ) = delete ;
A class that encapsulates a network socket file descriptor and an associated windows event handle.
A base class for classes that handle asynchronous events from the event loop.
An abstract base class for a singleton that keeps track of open sockets and their associated handlers...
virtual ~EventLoop()
Destructor.
virtual void dropWrite(Descriptor fd) noexcept=0
Removes the given event source descriptor from the list of write sources.
virtual bool running() const =0
Returns true if called from within run().
static std::unique_ptr< EventLoop > create()
A factory method which creates an instance of a derived class on the heap.
virtual void quit(const G::SignalSafe &)=0
A signal-safe overload to quit() the event loop.
static void stop(const G::SignalSafe &)
Calls quit() on instance().
virtual void dropRead(Descriptor fd) noexcept=0
Removes the given event source descriptor from the list of read sources.
static EventLoop * ptr() noexcept
Returns a pointer to an instance of the class, if any.
virtual void addOther(Descriptor fd, EventHandler &, ExceptionSink)=0
Adds the given event source descriptor and associated handler to the exception list.
static bool exists()
Returns true if an instance exists.
virtual void disarm(ExceptionHandler *) noexcept=0
Used to prevent the given interface from being used, typically called from the ExceptionHandler destr...
virtual void quit(const std::string &reason)=0
Causes run() to return (once the call stack has unwound).
virtual void addWrite(Descriptor fd, EventHandler &, ExceptionSink)=0
Adds the given event source descriptor and associated handler to the write list.
virtual std::string run()=0
Runs the main event loop.
static EventLoop & instance()
Returns a reference to an instance of the class, if any.
virtual void addRead(Descriptor fd, EventHandler &, ExceptionSink)=0
Adds the given event source descriptor and associated handler to the read list.
virtual void dropOther(Descriptor fd) noexcept=0
Removes the given event source descriptor from the list of exception sources.
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket/future event...
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
An empty structure that is used to indicate a signal-safe, reentrant implementation.