E-MailRelay
Public Member Functions | List of all members
GNet::EventEmitter Class Reference

An EventHandler and ExceptionSink tuple, with methods to raise an event and handle any exceptions. More...

#include <geventemitter.h>

Public Member Functions

 EventEmitter () noexcept
 Default constructor. More...
 
 EventEmitter (EventHandler *, ExceptionSink) noexcept
 Constructor. More...
 
void raiseReadEvent (Descriptor)
 Calls the EventHandler readEvent() method. More...
 
void raiseWriteEvent (Descriptor)
 Calls the EventHandler writeEvent() method. More...
 
void raiseOtherEvent (Descriptor, EventHandler::Reason)
 Calls the EventHandler otherEvent() method. More...
 
EventHandlerhandler () const
 Returns the handler, as passed to the ctor. More...
 
ExceptionSink es () const
 Returns the exception sink, as passed to the ctor. More...
 
void update (EventHandler *, ExceptionSink) noexcept
 Sets the event handler and the exception sink. More...
 
void reset () noexcept
 Resets the EventHandler so that the raise methods do nothing. More...
 
void disarm (ExceptionHandler *) noexcept
 If the exception handler matches then reset it so that it is not called. More...
 

Detailed Description

An EventHandler and ExceptionSink tuple, with methods to raise an event and handle any exceptions.

Used in EventLoop implementations. Also sets an appropriate G::LogOutput context while events are being handled.

The event loop should normally instantiate a read emitter and a write emitter for each new file descriptor; any existing emitters should be update()d rather than destructed and constructed, with garbage collection once all the events have been handled.

Definition at line 45 of file geventemitter.h.

Constructor & Destructor Documentation

◆ EventEmitter() [1/2]

GNet::EventEmitter::EventEmitter ( )
defaultnoexcept

Default constructor.

The raise methods do nothing and consequently the exception sink is not used. Postcondition: !handler()

◆ EventEmitter() [2/2]

GNet::EventEmitter::EventEmitter ( EventHandler handler,
ExceptionSink  es 
)
noexcept

Constructor.

Definition at line 31 of file geventemitter.cpp.

Member Function Documentation

◆ disarm()

void GNet::EventEmitter::disarm ( ExceptionHandler eh)
noexcept

If the exception handler matches then reset it so that it is not called.

Any exceptions will be thrown out of of the event loop and back to main().

Definition at line 116 of file geventemitter.cpp.

◆ es()

GNet::ExceptionSink GNet::EventEmitter::es ( ) const
inline

Returns the exception sink, as passed to the ctor.

Definition at line 102 of file geventemitter.h.

◆ handler()

GNet::EventHandler * GNet::EventEmitter::handler ( ) const
inline

Returns the handler, as passed to the ctor.

Definition at line 96 of file geventemitter.h.

◆ raiseOtherEvent()

void GNet::EventEmitter::raiseOtherEvent ( Descriptor  fd,
EventHandler::Reason  reason 
)

Calls the EventHandler otherEvent() method.

Definition at line 53 of file geventemitter.cpp.

◆ raiseReadEvent()

void GNet::EventEmitter::raiseReadEvent ( Descriptor  fd)

Calls the EventHandler readEvent() method.

Definition at line 43 of file geventemitter.cpp.

◆ raiseWriteEvent()

void GNet::EventEmitter::raiseWriteEvent ( Descriptor  fd)

Calls the EventHandler writeEvent() method.

Definition at line 48 of file geventemitter.cpp.

◆ reset()

void GNet::EventEmitter::reset ( )
noexcept

Resets the EventHandler so that the raise methods do nothing.

Postcondition: !handler()

Definition at line 111 of file geventemitter.cpp.

◆ update()

void GNet::EventEmitter::update ( EventHandler handler,
ExceptionSink  es 
)
noexcept

Sets the event handler and the exception sink.

Definition at line 37 of file geventemitter.cpp.


The documentation for this class was generated from the following files: