73 return static_cast<TypeId>(
reinterpret_cast<std::size_t
>(&type<T>::id));
85class QB_LOCKFREE_CACHELINE_ALIGNMENT Event {
86 friend class SharedCoreCommunication;
87 friend class VirtualCore;
90 friend struct EventQOS0;
91 friend struct ServiceEvent;
94 using id_handler_type =
ActorId;
103 template <
typename T>
104 [[nodiscard]]
constexpr static id_type
106 return static_cast<id_type
>(
reinterpret_cast<std::size_t
>(&qb::type<T>::id));
109 using id_type =
const char *;
115 template <
typename T>
116 [[nodiscard]]
constexpr static id_type
118 return typeid(T).name();
124 uint32_t : 16, : 8, alive : 1, qos : 2, factor : 5;
125 uint8_t prot[4] = {
'q',
'b',
'\0',
126 4 | ((QB_LOCKFREE_EVENT_BUCKET_BYTES / 16) << 3)};
128 uint16_t bucket_size;
131 id_handler_type dest;
132 id_handler_type source;
143 [[nodiscard]]
inline bool
151 [[nodiscard]]
inline id_type
159 [[nodiscard]]
inline uint8_t
167 [[nodiscard]]
inline id_handler_type
175 [[nodiscard]]
inline id_handler_type
183 [[nodiscard]]
inline std::size_t
185 return static_cast<std::size_t
>(bucket_size) * QB_LOCKFREE_EVENT_BUCKET_BYTES;
214struct EventQOS0 :
public Event {
229struct ServiceEvent :
public Event {
230 id_handler_type forward;
231 id_type service_event_id;
238 std::swap(dest, forward);
239 std::swap(
id, service_event_id);
298struct PingEvent :
public Event {
301 explicit PingEvent(uint32_t
const actor_type) noexcept
302 : type(actor_type) {}
310struct RequireEvent :
public Event {
314 explicit RequireEvent(uint32_t
const actor_type,
317 , status(actor_status) {}
326template <
typename... _Args>
327struct WithData :
public Event {
328 std::tuple<_Args...> data;
330 explicit WithData(_Args &&...args)
331 : data(std::forward<_Args>(args)...) {}
340template <
typename... _Args>
349template <
typename... _Args>
358template <
typename... _Args>
359struct FillEvent :
public WithData<_Args...> {
360 using base_t = WithData<_Args...>;
361 FillEvent() =
default;
362 explicit FillEvent(_Args &&...args)
363 : base_t(std::forward<_Args>(args)...) {}
Unique identifier for actors.
Definition ActorId.h:374
Base class for all events in the actor system.
Definition Event.h:85
std::size_t getSize() const noexcept
Get the size of the event in bytes.
Definition Event.h:184
id_handler_type getSource() const noexcept
Get the source actor ID.
Definition Event.h:176
static constexpr id_type type_to_id()
Get the type identifier at runtime.
Definition Event.h:117
id_handler_type getDestination() const noexcept
Get the destination actor ID.
Definition Event.h:168
id_type getID() const noexcept
Get the event's type ID for event routing and handling.
Definition Event.h:152
uint8_t getQOS() const noexcept
Get the event's quality of service level.
Definition Event.h:160
bool is_alive() const noexcept
Check if the event is still alive and can be processed.
Definition Event.h:144
Event template without data payload.
Definition Event.h:341
Extensible buffer optimized for performance.
Definition pipe.h:552
Actor and core identification for the QB Actor Framework.
Callback interface for the QB Actor Framework.
uint16_t TypeId
Type definition for type identifiers.
Definition ActorId.h:67
TypeId EventId
Type definition for event identifiers.
Definition ActorId.h:75
Event event
Alias for the base Event class.
Definition Event.h:385
constexpr TypeId type_id()
Function to get a unique type identifier for a given type.
Definition Event.h:72
Event EventQOS2
Event with highest quality of service (priority level 2)
Definition Event.h:197
allocator::pipe< EventBucket > VirtualPipe
Pipe for event transmission in the actor system.
Definition Event.h:375
ActorStatus
Represents the current status of an actor in the system.
Definition Event.h:286
Event EventQOS1
Event with medium quality of service (priority level 1)
Definition Event.h:207
ServiceEvent service_event
Alias for the ServiceEvent class.
Definition Event.h:395
@ Dead
The actor has been terminated or removed from the system.
Definition Event.h:290
@ Alive
The actor is active and operational.
Definition Event.h:288
Event template for requesting data, typically without carrying data itself.
Definition Event.h:350
Event used to terminate an actor.
Definition Event.h:258
Event type for service-to-service communication.
Definition Event.h:229
void received() noexcept
Mark the event as received and swap source/destination.
Definition Event.h:237
void live(bool flag) noexcept
Set the event's alive status.
Definition Event.h:248
Event used to handle system signals.
Definition Event.h:272
Event used to unregister an actor's callback.
Definition Event.h:265
Template struct used for type identification in the event system.
Definition Event.h:53
Implementation of a dynamic extensible buffer.