SObjectizer  5.8
Loading...
Searching...
No Matches
so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin > Class Template Referencefinal

A multi-producer/single-consumer mbox definition. More...

#include <mpsc_mbox.hpp>

Inheritance diagram for so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >:
so_5::abstract_message_box_t so_5::atomic_refcounted_t

Public Member Functions

template<typename... Tracing_Args>
 mpsc_mbox_template_t (mbox_id_t id, environment_t &env, outliving_reference_t< agent_t > owner, Tracing_Args &&... tracing_args)
 
mbox_id_t id () const override
 Unique ID of this mbox.
 
void subscribe_event_handler (const std::type_index &msg_type, abstract_message_sink_t &subscriber) override
 Add the message handler.
 
void unsubscribe_event_handler (const std::type_index &msg_type, abstract_message_sink_t &subscriber) noexcept override
 Remove all message handlers.
 
std::string query_name () const override
 Get the mbox name.
 
mbox_type_t type () const override
 Get the type of message box.
 
void do_deliver_message (message_delivery_mode_t delivery_mode, const std::type_index &msg_type, const message_ref_t &message, unsigned int redirection_deep) override
 Deliver message for all subscribers with respect to message limits.
 
void set_delivery_filter (const std::type_index &msg_type, const delivery_filter_t &filter, abstract_message_sink_t &subscriber) override
 Set a delivery filter for message type and subscriber.
 
void drop_delivery_filter (const std::type_index &msg_type, abstract_message_sink_t &) noexcept override
 Removes delivery filter for message type and subscriber.
 
environment_tenvironment () const noexcept override
 SObjectizer Environment for which the mbox is created.
 
- Public Member Functions inherited from so_5::abstract_message_box_t
 abstract_message_box_t ()=default
 
virtual ~abstract_message_box_t () noexcept=default
 

Protected Types

using subscription_info_t = local_mbox_details::subscription_info_with_sink_t
 Information related to a subscribed message type.
 
using subscriptions_map_t
 Type of dictionary for information about the current subscriptions.
 

Protected Member Functions

template<typename Info_Maker , typename Info_Changer >
void insert_or_modify_subscription (const std::type_index &msg_type, Info_Maker maker, Info_Changer changer)
 Helper for performing insertion or modification of subscription info.
 
template<typename Info_Changer >
void modify_and_remove_subscription_if_needed (const std::type_index &msg_type, Info_Changer changer)
 Helper for modification and deletion of subscription info.
 
template<typename L >
void do_delivery (const std::type_index &msg_type, const message_ref_t &message, typename Tracing_Base::deliver_op_tracer const &tracer, L l)
 Helper method to do delivery actions under locked object.
 
- Protected Member Functions inherited from so_5::atomic_refcounted_t
 atomic_refcounted_t (const atomic_refcounted_t &)=delete
 
atomic_refcounted_toperator= (const atomic_refcounted_t &)=delete
 
 atomic_refcounted_t () noexcept
 Default constructor.
 
 ~atomic_refcounted_t () noexcept=default
 Destructor.
 
void inc_ref_count () noexcept
 Increments reference count.
 
unsigned long dec_ref_count () noexcept
 Decrement reference count.
 

Protected Attributes

const mbox_id_t m_id
 ID of this mbox.
 
environment_tm_env
 Environment in that the mbox was created.
 
default_rw_spinlock_t m_lock
 Protection of object from modification.
 
subscriptions_map_t m_subscriptions
 Information about the current subscriptions.
 

Detailed Description

template<typename Tracing_Base, typename Limits_Handling_Mixin>
class so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >

A multi-producer/single-consumer mbox definition.

Since
v.5.4.0, v.5.7.1
Note
Renamed from limitful_mpsc_mbox_t to limitful_mpsc_mbox_template in v.5.5.9.
Renamed from limitful_mpsc_mbox_template to limitful_mpsc_mbox_template_t in v.5.7.1.
Renamed from limitful_mpsc_mbox_template_t to mpsc_mbox_template_t in v.5.7.4.

Definition at line 155 of file mpsc_mbox.hpp.

Member Typedef Documentation

◆ subscription_info_t

template<typename Tracing_Base , typename Limits_Handling_Mixin >
using so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::subscription_info_t = local_mbox_details::subscription_info_with_sink_t
protected

Information related to a subscribed message type.

Since
v.5.7.4

Definition at line 329 of file mpsc_mbox.hpp.

◆ subscriptions_map_t

template<typename Tracing_Base , typename Limits_Handling_Mixin >
using so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::subscriptions_map_t
protected
Initial value:
std::map<
std::type_index,
local_mbox_details::subscription_info_with_sink_t subscription_info_t
Information related to a subscribed message type.

Type of dictionary for information about the current subscriptions.

Since
v.5.7.1

Definition at line 337 of file mpsc_mbox.hpp.

Constructor & Destructor Documentation

◆ mpsc_mbox_template_t()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
template<typename... Tracing_Args>
so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::mpsc_mbox_template_t ( mbox_id_t id,
environment_t & env,
outliving_reference_t< agent_t > owner,
Tracing_Args &&... tracing_args )
inline

Definition at line 162 of file mpsc_mbox.hpp.

Member Function Documentation

◆ do_deliver_message()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
void so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::do_deliver_message ( message_delivery_mode_t delivery_mode,
const std::type_index & msg_type,
const message_ref_t & message,
unsigned int redirection_deep )
inlineoverridevirtual

Deliver message for all subscribers with respect to message limits.

Since
v.5.5.4

A message delivery from timer thread is somewhat different from an ordinary message delivery. Especially in the case when target mbox is a message chain. If that message chain is full and some kind of overflow reaction is specified (like waiting for some time or throwing an exception) then it can lead to undesired behaviour of the whole application. To take care about these cases a new method is introduced.

Note
Since v.5.6.0 this method is used for deliverance of ordinary messages/signals and for deliverance of enveloped messages.
Parameters
delivery_modeCan the delivery blocks the current thread?
msg_typeType of the message to deliver.
messageA message instance to be delivered.
redirection_deepCurrent deep of overlimit reaction recursion.

Implements so_5::abstract_message_box_t.

Definition at line 244 of file mpsc_mbox.hpp.

◆ do_delivery()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
template<typename L >
void so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::do_delivery ( const std::type_index & msg_type,
const message_ref_t & message,
typename Tracing_Base::deliver_op_tracer const & tracer,
L l )
inlineprotected

Helper method to do delivery actions under locked object.

Since
v.5.5.9
Template Parameters
Llambda with actual delivery actions.
Parameters
msg_typeType of message/signal to be delivered.
messageMessage object to be delivered.
tracerTracer object to log the case of abscense of subscriptions.
lLambda with actual delivery actions.

Definition at line 433 of file mpsc_mbox.hpp.

◆ drop_delivery_filter()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
void so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::drop_delivery_filter ( const std::type_index & msg_type,
abstract_message_sink_t & subscriber )
inlineoverridevirtualnoexcept

Removes delivery filter for message type and subscriber.

Since
v.5.5.5

Implements so_5::abstract_message_box_t.

Definition at line 304 of file mpsc_mbox.hpp.

◆ environment()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
environment_t & so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::environment ( ) const
inlineoverridevirtualnoexcept

SObjectizer Environment for which the mbox is created.

Since
v.5.6.0

Implements so_5::abstract_message_box_t.

Definition at line 318 of file mpsc_mbox.hpp.

◆ id()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
mbox_id_t so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::id ( ) const
inlineoverridevirtual

Unique ID of this mbox.

Since
v.5.4.0

Implements so_5::abstract_message_box_t.

Definition at line 174 of file mpsc_mbox.hpp.

◆ insert_or_modify_subscription()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
template<typename Info_Maker , typename Info_Changer >
void so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::insert_or_modify_subscription ( const std::type_index & msg_type,
Info_Maker maker,
Info_Changer changer )
inlineprotected

Helper for performing insertion or modification of subscription info.

Since
v.5.7.4

Definition at line 384 of file mpsc_mbox.hpp.

◆ modify_and_remove_subscription_if_needed()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
template<typename Info_Changer >
void so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::modify_and_remove_subscription_if_needed ( const std::type_index & msg_type,
Info_Changer changer )
inlineprotected

Helper for modification and deletion of subscription info.

Since
v.5.7.4

Definition at line 410 of file mpsc_mbox.hpp.

◆ query_name()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
std::string so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::query_name ( ) const
inlineoverridevirtual

Get the mbox name.

Implements so_5::abstract_message_box_t.

Definition at line 229 of file mpsc_mbox.hpp.

◆ set_delivery_filter()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
void so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::set_delivery_filter ( const std::type_index & msg_type,
const delivery_filter_t & filter,
abstract_message_sink_t & subscriber )
inlineoverridevirtual

Set a delivery filter for message type and subscriber.

Since
v.5.5.5
Note
If there already is a delivery filter for that (msg_type,subscriber) pair then old delivery filter will be replaced by new one.
Parameters
msg_typeMessage type to be filtered.
filterFilter to be set. A caller must guaranted the validity of this reference.
subscriberA subscriber for the message.

Implements so_5::abstract_message_box_t.

Definition at line 282 of file mpsc_mbox.hpp.

◆ subscribe_event_handler()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
void so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::subscribe_event_handler ( const std::type_index & type_index,
abstract_message_sink_t & subscriber )
inlineoverridevirtual

Add the message handler.

Parameters
type_indexMessage type.
subscriberSubscriber.

Implements so_5::abstract_message_box_t.

Definition at line 180 of file mpsc_mbox.hpp.

◆ type()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
mbox_type_t so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::type ( ) const
inlineoverridevirtual

Get the type of message box.

Since
v.5.5.3
Note
This method is primarily intended for internal usage. It is useful sometimes in subscription-related operations because there is no need to do some actions for MPSC mboxes.

Implements so_5::abstract_message_box_t.

Definition at line 238 of file mpsc_mbox.hpp.

◆ unsubscribe_event_handler()

template<typename Tracing_Base , typename Limits_Handling_Mixin >
void so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::unsubscribe_event_handler ( const std::type_index & type_index,
abstract_message_sink_t & subscriber )
inlineoverridevirtualnoexcept

Remove all message handlers.

Parameters
type_indexMessage type.
subscriberSubscriber.

Implements so_5::abstract_message_box_t.

Definition at line 201 of file mpsc_mbox.hpp.

Member Data Documentation

◆ m_env

template<typename Tracing_Base , typename Limits_Handling_Mixin >
environment_t& so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::m_env
protected

Environment in that the mbox was created.

Note
Previous versions of SObjectizer didn't hold this reference in MPSC-mbox implementations. Instead, the reference was obtained via m_single_consumer. But this approach lead to access violation when MPSC-mbox's environment() method was called after the deregistration of m_single_consumer. Because of than the reference to SOEnv is stored inside MPSC-mbox and is returned by environment() method.
Since
v.5.7.5

Definition at line 360 of file mpsc_mbox.hpp.

◆ m_id

template<typename Tracing_Base , typename Limits_Handling_Mixin >
const mbox_id_t so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::m_id
protected

ID of this mbox.

Definition at line 344 of file mpsc_mbox.hpp.

◆ m_lock

template<typename Tracing_Base , typename Limits_Handling_Mixin >
default_rw_spinlock_t so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::m_lock
protected

Protection of object from modification.

Since
v.5.5.9

Definition at line 367 of file mpsc_mbox.hpp.

◆ m_subscriptions

template<typename Tracing_Base , typename Limits_Handling_Mixin >
subscriptions_map_t so_5::impl::mpsc_mbox_template_t< Tracing_Base, Limits_Handling_Mixin >::m_subscriptions
protected

Information about the current subscriptions.

Since
v.5.7.1

Definition at line 374 of file mpsc_mbox.hpp.


The documentation for this class was generated from the following file: