qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
qb::ServiceActor< Tag > Class Template Reference

SingletonActor base class, ensuring one instance per VirtualCore per Tag. More...

#include <Actor.h>

Inheritance diagram for qb::ServiceActor< Tag >:
Collaboration diagram for qb::ServiceActor< Tag >:

Additional Inherited Members

Public Member Functions inherited from qb::Service
 Service (ServiceId sid)
Public Member Functions inherited from qb::Actor
void on (KillEvent const &event) noexcept
 Handler for KillEvent.
void on (SignalEvent const &event) noexcept
 Handler for SignalEvent.
void on (UnregisterCallbackEvent const &event) noexcept
 Handler for UnregisterCallbackEvent.
void on (PingEvent const &event) noexcept
 Handler for PingEvent.
template<typename _Actor>
void registerCallback (_Actor &actor) const noexcept
 Register a looped callback for this actor.
template<typename _Actor>
void unregisterCallback (_Actor &actor) const noexcept
 Unregister a previously registered looped callback for this actor.
template<typename _Event, typename _Actor>
void registerEvent (_Actor &actor) const noexcept
 Subscribe this actor to listen for a specific event type.
template<typename _Event, typename _Actor>
void unregisterEvent (_Actor &actor) const noexcept
 Unsubscribe this actor from listening to a specific event type.
EventBuilder to (ActorId dest) const noexcept
 Get an EventBuilder for sending chained events to a destination actor.
template<typename _Event, typename... _Args>
_Event & push (ActorId const &dest, _Args &&...args) const noexcept
 Send a new event in an ordered fashion to a destination actor, returning a reference to it.
template<typename _Event, typename... _Args>
void send (ActorId const &dest, _Args &&...args) const noexcept
 Send a new event in an unordered fashion to a destination actor.
template<typename _Event, typename... _Args>
_Event build_event (qb::ActorId const source, _Args &&...args) const noexcept
 Construct an event locally, intended for immediate self-processing or direct calls.
template<typename _Type>
bool is (uint32_t const id) const noexcept
 Check if a given ID matches the type ID of _Type.
template<typename _Type>
bool is (RequireEvent const &event) const noexcept
 Check if a RequireEvent is for a specific actor type.
template<typename... _Actors>
bool require () const noexcept
 Request discovery of other actors of specified types.
template<typename _Event, typename... _Args>
void broadcast (_Args &&...args) const noexcept
 Broadcast an event to all actors on all cores.
void reply (Event &event) const noexcept
 Reply to the source of a received event, reusing the event object.
void forward (ActorId dest, Event &event) const noexcept
 Forward a received event to a new destination, reusing the event object.
Pipe getPipe (ActorId dest) const noexcept
 Get direct access to the underlying communication pipe for a destination actor.
template<typename _Actor, typename... _Args>
_Actor * addRefActor (_Args &&...args) const
 Create and initialize a new referenced actor on the same VirtualCore.
ActorId id () const noexcept
 Get ActorId.
CoreId getIndex () const noexcept
 Get core index.
std::string_view getName () const noexcept
 Get derived class name.
const CoreIdSetgetCoreSet () const noexcept
 Get the set of cores that this actor's VirtualCore can communicate with.
uint64_t time () const noexcept
 Get current time from the VirtualCore's perspective (nanoseconds since epoch).
template<typename _ServiceActor>
_ServiceActor * getService () const noexcept
 Get direct access to ServiceActor* in same core.
bool is_alive () const noexcept
 Check if Actor is alive and processing events.
void kill () const noexcept
 Terminate this actor and mark it for removal from the system.
 Actor () noexcept
 Default constructor.
virtual ~Actor () noexcept=default
 Virtual destructor.
virtual bool onInit ()
 Initialization callback, called once after construction and ID assignment.

Detailed Description

template<typename Tag>
class qb::ServiceActor< Tag >

SingletonActor base class, ensuring one instance per VirtualCore per Tag.

Template Parameters
TagA unique struct Tag to identify the service type.

ServiceActor is a special actor where DerivedActor must define a unique service index by Tag.
Inherited Service Actors are unique per VirtualCore.