76 thread_local static VirtualCore *_handler;
104 constexpr static const uint64_t MaxRingEvents =
105 ((std::numeric_limits<uint16_t>::max)() + 1) / QB_LOCKFREE_EVENT_BUCKET_BYTES;
107 using Mailbox = SharedCoreCommunication::Mailbox;
108 using EventBuffer = std::array<EventBucket, MaxRingEvents>;
111 using PipeMap = std::vector<VirtualPipe>;
113 using AvailableIdList = std::set<ServiceId>;
120 const CoreId _resolved_index;
124 std::unique_ptr<EventBuffer> _event_buffer;
129 std::unique_ptr<VirtualPipe> _mono_pipe;
131 AvailableIdList _ids;
133 CallbackMap _actor_callbacks;
134 RemoveActorList _actor_to_remove;
138 uint64_t _sleep_count = 0;
139 uint64_t _nb_event_io = 0;
140 uint64_t _nb_event_received = 0;
141 uint64_t _nb_bucket_received = 0;
142 uint64_t _nb_event_sent_try = 0;
143 uint64_t _nb_event_sent = 0;
144 uint64_t _nb_bucket_sent = 0;
145 uint64_t _nanotimer = 0;
150 *
this = {((_sleep_count + _nb_event_sent + _nb_event_received +
151 _nb_event_io + _nb_event_sent_try))};
158 ~VirtualCore() noexcept;
164 [[nodiscard]] ActorId __generate_id__() noexcept;
167 template <typename _Event, typename _Actor>
168 void registerEvent(_Actor &
actor) noexcept;
169 template <typename _Event, typename _Actor>
170 void unregisterEvent(_Actor &
actor) noexcept;
171 void unregisterEvents(ActorId
id) noexcept;
178 void __receive_events__(EventBucket *buffer, std::
size_t nb_events);
180 bool __flush_all__() noexcept;
185 bool __init__actors__() const;
196 [[nodiscard]] ActorId initActor(Actor &
actor,
bool doInit) noexcept;
203 [[nodiscard]] ActorId appendActor(Actor &
actor,
bool doInit = false) noexcept;
204 void removeActor(ActorId
id) noexcept;
215 template <typename _Actor, typename... _Init>
216 [[nodiscard]] _Actor *addReferencedActor(_Init &&...init) noexcept;
222 template <typename _ServiceActor>
223 [[nodiscard]] _ServiceActor *getService() const noexcept;
225 void killActor(ActorId
id) noexcept;
227 template <typename _Actor>
228 void registerCallback(_Actor &
actor) noexcept;
229 void __unregisterCallback(ActorId
id) noexcept;
230 void unregisterCallback(ActorId
id) noexcept;
240 [[nodiscard]] Pipe getProxyPipe(ActorId dest, ActorId source) noexcept;
246 [[nodiscard]]
bool try_send(Event const &
event) const noexcept;
247 void send(Event const &
event) noexcept;
253 Event &push(Event const &
event) noexcept;
254 void reply(Event &
event) noexcept;
255 void forward(ActorId dest, Event &
event) noexcept;
257 template <typename T>
258 static inline
void fill_event(T &data, ActorId dest, ActorId source) noexcept;
259 template <typename T, typename... _Init>
260 void send(ActorId dest, ActorId source, _Init &&...init) noexcept;
261 template <typename T, typename... _Init>
262 void broadcast(ActorId source, _Init &&...init) noexcept;
272 template <typename T, typename... _Init>
273 T &push(ActorId dest, ActorId source, _Init &&...init) noexcept;
277 VirtualCore() = delete;
308 [[nodiscard]] uint64_t
time() const noexcept;
The main controller for the QB Actor Framework engine.
Definition Main.h:408
Main control for the QB Actor Framework.
std::unordered_map< K, V, H, E, A > unordered_map
The primary unordered map implementation.
Definition unordered_map.h:90
std::unordered_set< K, H, E, A > unordered_set
The primary unordered set implementation.
Definition unordered_set.h:81