Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::internal::EventHandlerDelegate< EventType, InlineSize > Class Template Reference

Lightweight non-allocating delegate wrapper with 32-byte Small Buffer Optimization (SBO). Eliminates std::function heap allocations and virtual table overhead for event handlers. More...

#include <FastDelegate.hpp>

+ Inheritance diagram for corium::internal::EventHandlerDelegate< EventType, InlineSize >:
+ Collaboration diagram for corium::internal::EventHandlerDelegate< EventType, InlineSize >:

Public Member Functions

 EventHandlerDelegate () noexcept=default
 
 EventHandlerDelegate (const EventHandlerDelegate &)=delete
 
 EventHandlerDelegate (EventHandlerDelegate &&rhs) noexcept
 
template<typename Handler , typename Decayed = std::decay_t<Handler>, typename = std::enable_if_t< !std::is_same_v<Decayed, EventHandlerDelegate> && std::is_invocable_r_v<void, Decayed&, const EventType&> >>
 EventHandlerDelegate (Handler &&handler)
 Construct delegate wrapping a callable object (lambda, function pointer, or functor).
 
 EventHandlerDelegate (void *srcObj, void(*stub)(void *instance, const EventType &event), void(*moveFn)(void *destStorage, void *&destInstance, void *&srcInstance) noexcept, void(*destroyFn)(void *instance) noexcept) noexcept
 Construct delegate from type-erased thunk operations.
 
void invoke (const EventType &event) const
 Invoke wrapped handler directly with concrete event.
 
 operator bool () const noexcept
 Check if delegate wraps a valid handler.
 
void operator() (const EventType &event) const
 Function call operator for callable ergonomics.
 
EventHandlerDelegateoperator= (const EventHandlerDelegate &)=delete
 
EventHandlerDelegateoperator= (EventHandlerDelegate &&rhs) noexcept
 
void reset () noexcept
 Reset delegate to empty state.
 
 ~EventHandlerDelegate ()
 

Detailed Description

template<typename EventType, std::size_t InlineSize = 32>
class corium::internal::EventHandlerDelegate< EventType, InlineSize >

Lightweight non-allocating delegate wrapper with 32-byte Small Buffer Optimization (SBO). Eliminates std::function heap allocations and virtual table overhead for event handlers.

Template Parameters
EventTypeThe concrete event type invoked by this delegate.

Constructor & Destructor Documentation

◆ EventHandlerDelegate() [1/5]

template<typename EventType , std::size_t InlineSize = 32>
corium::internal::EventHandlerDelegate< EventType, InlineSize >::EventHandlerDelegate ( )
defaultnoexcept

◆ EventHandlerDelegate() [2/5]

template<typename EventType , std::size_t InlineSize = 32>
template<typename Handler , typename Decayed = std::decay_t<Handler>, typename = std::enable_if_t< !std::is_same_v<Decayed, EventHandlerDelegate> && std::is_invocable_r_v<void, Decayed&, const EventType&> >>
corium::internal::EventHandlerDelegate< EventType, InlineSize >::EventHandlerDelegate ( Handler &&  handler)
inlineexplicit

Construct delegate wrapping a callable object (lambda, function pointer, or functor).

Template Parameters
HandlerCallable type.
Parameters
handlerCallable instance.

◆ EventHandlerDelegate() [3/5]

template<typename EventType , std::size_t InlineSize = 32>
corium::internal::EventHandlerDelegate< EventType, InlineSize >::EventHandlerDelegate ( void *  srcObj,
void(*)(void *instance, const EventType &event)  stub,
void(*)(void *destStorage, void *&destInstance, void *&srcInstance) noexcept  moveFn,
void(*)(void *instance) noexcept  destroyFn 
)
inlinenoexcept

Construct delegate from type-erased thunk operations.

◆ ~EventHandlerDelegate()

template<typename EventType , std::size_t InlineSize = 32>
corium::internal::EventHandlerDelegate< EventType, InlineSize >::~EventHandlerDelegate ( )
inline
+ Here is the call graph for this function:

◆ EventHandlerDelegate() [4/5]

template<typename EventType , std::size_t InlineSize = 32>
corium::internal::EventHandlerDelegate< EventType, InlineSize >::EventHandlerDelegate ( EventHandlerDelegate< EventType, InlineSize > &&  rhs)
inlinenoexcept

◆ EventHandlerDelegate() [5/5]

template<typename EventType , std::size_t InlineSize = 32>
corium::internal::EventHandlerDelegate< EventType, InlineSize >::EventHandlerDelegate ( const EventHandlerDelegate< EventType, InlineSize > &  )
delete

Member Function Documentation

◆ invoke()

template<typename EventType , std::size_t InlineSize = 32>
void corium::internal::EventHandlerDelegate< EventType, InlineSize >::invoke ( const EventType &  event) const
inline

Invoke wrapped handler directly with concrete event.

Parameters
eventEvent instance to pass to handler.
+ Here is the caller graph for this function:

◆ operator bool()

template<typename EventType , std::size_t InlineSize = 32>
corium::internal::EventHandlerDelegate< EventType, InlineSize >::operator bool ( ) const
inlineexplicitnoexcept

Check if delegate wraps a valid handler.

◆ operator()()

template<typename EventType , std::size_t InlineSize = 32>
void corium::internal::EventHandlerDelegate< EventType, InlineSize >::operator() ( const EventType &  event) const
inline

Function call operator for callable ergonomics.

+ Here is the call graph for this function:

◆ operator=() [1/2]

template<typename EventType , std::size_t InlineSize = 32>
EventHandlerDelegate & corium::internal::EventHandlerDelegate< EventType, InlineSize >::operator= ( const EventHandlerDelegate< EventType, InlineSize > &  )
delete

◆ operator=() [2/2]

template<typename EventType , std::size_t InlineSize = 32>
EventHandlerDelegate & corium::internal::EventHandlerDelegate< EventType, InlineSize >::operator= ( EventHandlerDelegate< EventType, InlineSize > &&  rhs)
inlinenoexcept
+ Here is the call graph for this function:

◆ reset()

template<typename EventType , std::size_t InlineSize = 32>
void corium::internal::EventHandlerDelegate< EventType, InlineSize >::reset ( )
inlinenoexcept

Reset delegate to empty state.

+ Here is the caller graph for this function:

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