Public Member Functions | List of all members
event_base Class Referenceabstract

Common base class for all events. More...

#include <event.hpp>

Inheritance diagram for event_base:
Inheritance graph

Public Member Functions

 event_base (event_base const &)=default
event_baseoperator= (event_base const &)=default
 event_base (event_base &&)=default
event_baseoperator= (event_base &&)=default
virtual size_t derived_type () const =0

Detailed Description

Common base class for all events.

If possible, use simple_event<> below instead of deriving from event_base directly.

Keep events as simple as possible. Avoid mutexes in your events.

aio.cpp, events.cpp, https.cpp, nonblocking_process.cpp, raw_https.cpp, and timer_fizzbuzz.cpp.

Member Function Documentation

◆ derived_type()

virtual size_t derived_type ( ) const
pure virtual

The returned pointer must be unique for the derived type such that: event_base& a = ... event_base& b = ... assert((a.derived_type() == b.derived_type()) == (typeid(a) == typeid(b)));

Using &typeid is tempting, but unspecifined (sic)
According to the C++ standard, the address of a static member function is unique for each type. Unfortunately this does not prevent optimizing compilers to pool identical functions.

Best solution is to have your derived type return the address of a static data member of it, as done in simple_event.

Implemented in simple_event< UniqueType, Values >.

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