rotor
Event loop friendly C++ actor micro-framework
 
Loading...
Searching...
No Matches
lifetime.h
1#pragma once
2
3//
4// Copyright (c) 2019-2023 Ivan Baidakou (basiliscos) (the dot dmol at gmail dot com)
5//
6// Distributed under the MIT Software License
7//
8
9#include "plugin_base.h"
10
11namespace rotor::plugin {
12
21struct ROTOR_API lifetime_plugin_t : public plugin_base_t {
22 using plugin_base_t::plugin_base_t;
23
25 static const std::type_index class_identity;
26
27 const std::type_index &identity() const noexcept override;
28
29 void activate(actor_base_t *actor) noexcept override;
30 void deactivate() noexcept override;
31
33 void initate_subscription(const subscription_info_ptr_t &info) noexcept;
34
36 void unsubscribe(const handler_ptr_t &h, const address_ptr_t &addr) noexcept;
37
44 void unsubscribe(const subscription_info_ptr_t &info) noexcept;
45
50 virtual void on_subscription(message::subscription_t &) noexcept;
51
56 virtual void on_unsubscription(message::unsubscription_t &) noexcept;
57
62 virtual void on_unsubscription_external(message::unsubscription_external_t &) noexcept;
63
64 bool handle_unsubscription(const subscription_point_t &point, bool external) noexcept override;
65
66 bool handle_shutdown(message::shutdown_request_t *message) noexcept override;
67
69 template <typename T> auto &access() noexcept;
70
71 private:
72 void unsubscribe() noexcept;
73
76
77 bool ready_to_shutdown() noexcept;
78};
79
80} // namespace rotor::plugin
intrusive_ptr_t< address_t > address_ptr_t
intrusive pointer for address
Definition address.hpp:57
intrusive_ptr_t< handler_base_t > handler_ptr_t
intrusive pointer for handler
Definition forward.hpp:26
intrusive_ptr_t< subscription_info_t > subscription_info_ptr_t
intrusive pointer for subscription_info_t
Definition subscription_point.h:127
universal primitive of concurrent computation
Definition actor_base.h:47
manages all actor subscriptions (i.e. from plugins or actor itself).
Definition lifetime.h:21
const std::type_index & identity() const noexcept override
returns pointer, which uniquely identifiess plugin type
static const std::type_index class_identity
Definition lifetime.h:25
base class for all actor plugins
Definition plugin_base.h:23
list of subscription_info_ptr_t with possibility to find via subscription_point_t
Definition subscription_point.h:132
pair of handler_base_t linked to particular address_t
Definition subscription_point.h:50
Holds and classifies message handlers on behalf of supervisor.
Definition subscription.h:30