Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::BasicServiceRegistry< MaxServices, EventVariant > Class Template Reference

Non-allocating ServiceRegistry storing service handles in a fixed stack/static array. Zero heap allocations, zero vtables/RTTI. More...

#include <ServiceRegistry.hpp>

+ Inheritance diagram for corium::BasicServiceRegistry< MaxServices, EventVariant >:
+ Collaboration diagram for corium::BasicServiceRegistry< MaxServices, EventVariant >:

Classes

struct  ServiceHandle
 Non-allocating type-erased handle for static background services. More...
 

Public Types

using ServiceContextType = ServiceContextT< EventVariant >
 

Public Member Functions

 BasicServiceRegistry ()=default
 
template<typename ServiceType >
ServiceType * getService () const noexcept
 Retrieve a registered service instance by concrete type.
 
void * getServiceById (internal::TypeIdPtr typeId) const noexcept
 Retrieve a registered service instance by static type ID.
 
template<typename ServiceType >
EventSinkT< EventVariant > getServiceSink () const noexcept
 Retrieve event sink handle of a target registered service if available.
 
void initialize (ServiceContextType ctx)
 Initialize and launch all registered background service jthreads.
 
template<typename ServiceType >
bool registerService (ServiceType &serviceInstance)
 Register a background service instance by reference.
 
void shutdown () noexcept
 Stop and join all registered background service threads.
 
size_t size () const noexcept
 Access number of registered services.
 

Detailed Description

template<size_t MaxServices = 8, typename EventVariant = DefaultEvents>
class corium::BasicServiceRegistry< MaxServices, EventVariant >

Non-allocating ServiceRegistry storing service handles in a fixed stack/static array. Zero heap allocations, zero vtables/RTTI.

Template Parameters
MaxServicesMaximum number of background services allowed per registry (default 8).
EventVariantSupported event variant type list.

Member Typedef Documentation

◆ ServiceContextType

template<size_t MaxServices = 8, typename EventVariant = DefaultEvents>
using corium::BasicServiceRegistry< MaxServices, EventVariant >::ServiceContextType = ServiceContextT<EventVariant>

Constructor & Destructor Documentation

◆ BasicServiceRegistry()

template<size_t MaxServices = 8, typename EventVariant = DefaultEvents>
corium::BasicServiceRegistry< MaxServices, EventVariant >::BasicServiceRegistry ( )
default

Member Function Documentation

◆ getService()

template<size_t MaxServices = 8, typename EventVariant = DefaultEvents>
template<typename ServiceType >
ServiceType * corium::BasicServiceRegistry< MaxServices, EventVariant >::getService ( ) const
inlinenoexcept

Retrieve a registered service instance by concrete type.

Template Parameters
ServiceTypeType of the background service.
Returns
Pointer to registered ServiceType instance, or nullptr if not found.
+ Here is the call graph for this function:

◆ getServiceById()

template<size_t MaxServices = 8, typename EventVariant = DefaultEvents>
void * corium::BasicServiceRegistry< MaxServices, EventVariant >::getServiceById ( internal::TypeIdPtr  typeId) const
inlinenoexcept

Retrieve a registered service instance by static type ID.

+ Here is the caller graph for this function:

◆ getServiceSink()

template<size_t MaxServices = 8, typename EventVariant = DefaultEvents>
template<typename ServiceType >
EventSinkT< EventVariant > corium::BasicServiceRegistry< MaxServices, EventVariant >::getServiceSink ( ) const
inlinenoexcept

Retrieve event sink handle of a target registered service if available.

Template Parameters
ServiceTypeType of the target background service.
Returns
EventSinkT handle targeting the service's incoming queue, or empty handle if unavailable.

◆ initialize()

template<size_t MaxServices = 8, typename EventVariant = DefaultEvents>
void corium::BasicServiceRegistry< MaxServices, EventVariant >::initialize ( ServiceContextType  ctx)
inline

Initialize and launch all registered background service jthreads.

+ Here is the call graph for this function:

◆ registerService()

template<size_t MaxServices = 8, typename EventVariant = DefaultEvents>
template<typename ServiceType >
bool corium::BasicServiceRegistry< MaxServices, EventVariant >::registerService ( ServiceType &  serviceInstance)
inline

Register a background service instance by reference.

Template Parameters
ServiceTypeType of the background service.
Parameters
serviceInstanceReference to service instance.
Returns
true if service was registered successfully; false if registry is full.

◆ shutdown()

template<size_t MaxServices = 8, typename EventVariant = DefaultEvents>
void corium::BasicServiceRegistry< MaxServices, EventVariant >::shutdown ( )
inlinenoexcept

Stop and join all registered background service threads.

◆ size()

template<size_t MaxServices = 8, typename EventVariant = DefaultEvents>
size_t corium::BasicServiceRegistry< MaxServices, EventVariant >::size ( ) const
inlinenoexcept

Access number of registered services.


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