31#ifndef ETL_SHARED_MESSAGE_INCLUDED
32#define ETL_SHARED_MESSAGE_INCLUDED
36#include "reference_counted_message.h"
40#include "static_assert.h"
56 template <
typename TMessage,
typename TPool,
typename... TArgs>
66 template <
typename TPool,
typename TMessage>
72 p_rcmessage = owner.allocate(
message);
74 if (p_rcmessage != ETL_NULLPTR)
76 p_rcmessage->get_reference_counter().set_reference_count(1U);
84 template <
typename TPool,
typename TMessage,
typename... TArgs>
90 p_rcmessage = owner.template allocate<TMessage>(etl::forward<TArgs>(args)...);
92 if (p_rcmessage != ETL_NULLPTR)
113 : p_rcmessage(other.p_rcmessage)
115 p_rcmessage->get_reference_counter().increment_reference_count();
123 : p_rcmessage(etl::move(other.p_rcmessage))
125 other.p_rcmessage = ETL_NULLPTR;
137 if (p_rcmessage->get_reference_counter().decrement_reference_count() == 0U)
139 p_rcmessage->release();
143 p_rcmessage = other.p_rcmessage;
165 p_rcmessage = etl::move(other.p_rcmessage);
166 other.p_rcmessage = ETL_NULLPTR;
179 if ((p_rcmessage != ETL_NULLPTR) &&
180 (p_rcmessage->get_reference_counter().decrement_reference_count() == 0U))
182 p_rcmessage->release();
191 return p_rcmessage->get_message();
199 return p_rcmessage->get_message();
207 return p_rcmessage->get_reference_counter().get_reference_count();
215 return p_rcmessage != ETL_NULLPTR;
Definition reference_counted_message.h:48
virtual ETL_NODISCARD etl::ireference_counter & get_reference_counter()=0
Get a reference to the reference counter.
virtual void release()=0
Release back to the owner.
Definition shared_message.h:49
ETL_NODISCARD bool is_valid() const
Checks if the shared message is valid.
Definition shared_message.h:213
ETL_NODISCARD uint32_t get_reference_count() const
Get the current reference count for this shared message.
Definition shared_message.h:205
ETL_NODISCARD etl::imessage & get_message()
Get a reference to the contained message.
Definition shared_message.h:189
shared_message(const etl::shared_message &other)
Copy constructor.
Definition shared_message.h:112
~shared_message()
Definition shared_message.h:177
ETL_NODISCARD const etl::imessage & get_message() const
Get a const reference to the contained message.
Definition shared_message.h:197
shared_message(etl::ireference_counted_message &rcm)
Constructor.
Definition shared_message.h:102
shared_message(TPool &owner, const TMessage &message)
Constructor.
Definition shared_message.h:67
shared_message & operator=(const etl::shared_message &other)
Copy assignment operator.
Definition shared_message.h:132
is_base_of
Definition type_traits_generator.h:1315
bitset_ext
Definition absolute.h:39
T * create(Args &&... args)
Creates the object from a type. Variadic parameter constructor.
Definition variant_pool_generator.h:348