Go to the documentation of this file.
9 #ifndef EAGINE_MESSAGE_BUS_SERVICE_SHUTDOWN_HPP
10 #define EAGINE_MESSAGE_BUS_SERVICE_SHUTDOWN_HPP
12 #include "../serialize.hpp"
13 #include "../subscriber.hpp"
19 using shutdown_service_clock = std::chrono::system_clock;
20 using shutdown_service_duration =
21 std::chrono::duration<std::int64_t, std::milli>;
23 template <
typename Base = subscriber>
26 ,
protected shutdown_service_clock {
27 using This = shutdown_target;
39 virtual void on_shutdown(
40 std::chrono::milliseconds age,
45 auto _handle_shutdown(
const message_context&, stored_message& message)
47 typename shutdown_service_duration::rep count{0};
49 const shutdown_service_duration ticks{count};
50 const typename shutdown_service_clock::time_point ts{ticks};
51 const auto age{this->now() - ts};
53 std::chrono::duration_cast<std::chrono::milliseconds>(age),
55 this->verify_bits(message));
61 template <
typename Base = subscriber>
62 class shutdown_invoker
64 ,
protected shutdown_service_clock {
66 using This = shutdown_invoker;
73 std::array<byte, 32> temp{};
74 const auto ts{this->now()};
75 const auto ticks{std::chrono::duration_cast<shutdown_service_duration>(
76 ts.time_since_epoch())};
77 const auto count{ticks.count()};
79 EAGINE_ASSERT(serialized);
82 message.set_target_id(target_id);
89 #endif // EAGINE_MESSAGE_BUS_SERVICE_SHUTDOWN_HPP
bitfield< verification_bit > verification_bits
Alias for a bus message verification bitfield.
Definition: verification.hpp:47
#define EAGINE_MSG_MAP(CLASS_ID, METHOD_ID, CLASS, METHOD)
Constructs an instance of static message handler map.
Definition: handler_map.hpp:72
#define EAGINE_MSG_ID(API, NAME)
Macro for instantiating objects of static_message_id.
Definition: message_id.hpp:148
static constexpr auto cover(T *addr, S size) noexcept -> span_if_mutable< T >
Creates a span starting at the specified pointer and specified length.
Definition: span.hpp:465
static constexpr auto extract(api_result_value< Result, api_result_validity::never > &) noexcept -> Result &
Overload of extract for api_result_value.
Definition: c_api_wrap.hpp:270
auto default_serialize(T &value, memory::block blk) -> serialization_result< memory::const_block >
Uses the default backend to serialize a value into a memory block.
Definition: serialize.hpp:191
Message bus code is placed in this namespace.
Definition: eagine.hpp:58
auto default_deserialize(T &value, memory::const_block blk) -> deserialization_result< memory::const_block >
Uses the default backend to deserialize a value from a memory block.
Definition: serialize.hpp:235
@ message
Message protocol.
std::uint64_t identifier_t
The underlying integer type for eagine::identifier.
Definition: identifier_t.hpp:19
auto bus() noexcept -> auto &
Returns a reference to the associated endpoint.
Definition: subscriber.hpp:38