1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #pragma once
- #include "plugin_base.h"
- #include <string>
- #if !defined(NDEBUG) && !defined(ROTOR_DEBUG_DELIVERY)
- #define ROTOR_DO_DELIVERY_DEBUG 1
- #endif
- namespace rotor::plugin {
- struct local_delivery_t {
-
- static void delivery(message_ptr_t &message, const subscription_t::joint_handlers_t &local_recipients) noexcept;
- };
- struct inspected_local_delivery_t {
-
- static std::string identify(const message_base_t *message, int32_t threshold) noexcept;
-
- static void delivery(message_ptr_t &message, const subscription_t::joint_handlers_t &local_recipients) noexcept;
-
- static void discard(message_ptr_t &message) noexcept;
- };
- #if !defined(ROTOR_DO_DELIVERY_DEBUG)
- using default_local_delivery_t = local_delivery_t;
- #else
- using default_local_delivery_t = inspected_local_delivery_t;
- #endif
- struct delivery_plugin_base_t : public plugin_base_t {
- using plugin_base_t::plugin_base_t;
-
- virtual void process() noexcept = 0;
- void activate(actor_base_t *actor) noexcept override;
- protected:
-
- messages_queue_t *queue = nullptr;
-
- address_t *address = nullptr;
-
- subscription_t *subscription_map;
- };
- template <typename LocalDelivery = local_delivery_t> struct delivery_plugin_t : public delivery_plugin_base_t {
- using delivery_plugin_base_t::delivery_plugin_base_t;
-
- static const void *class_identity;
- const void *identity() const noexcept override { return class_identity; }
- inline void process() noexcept override;
- };
- template <typename LocalDelivery>
- const void *
- delivery_plugin_t<LocalDelivery>::class_identity = static_cast<const void *>(typeid(local_delivery_t).name());
- }
|