SObjectizer
5.5
|
Template-based implementation of message chain. More...
#include <mchain_details.hpp>
Public Member Functions | |
template<typename... Tracing_Args> | |
mchain_template (so_5::environment_t &env, mbox_id_t id, const mchain_params_t ¶ms, Tracing_Args &&... tracing_args) | |
Initializing constructor. More... | |
virtual mbox_id_t | id () const override |
Unique ID of this mbox. More... | |
virtual void | subscribe_event_handler (const std::type_index &, const so_5::message_limit::control_block_t *, agent_t *) override |
Add the message handler. More... | |
virtual void | unsubscribe_event_handlers (const std::type_index &, agent_t *) override |
Remove all message handlers. More... | |
virtual std::string | query_name () const override |
Get the mbox name. More... | |
virtual mbox_type_t | type () const override |
Get the type of message box. More... | |
virtual void | do_deliver_message (const std::type_index &msg_type, const message_ref_t &message, unsigned int) const override |
Deliver message for all subscribers with respect to message limits. More... | |
virtual void | do_deliver_service_request (const std::type_index &msg_type, const message_ref_t &message, unsigned int) const override |
Deliver service request. More... | |
void | do_deliver_enveloped_msg (const std::type_index &msg_type, const message_ref_t &message, unsigned int) override |
Deliver enveloped message. More... | |
virtual void | set_delivery_filter (const std::type_index &, const delivery_filter_t &, agent_t &) override |
virtual void | drop_delivery_filter (const std::type_index &, agent_t &) SO_5_NOEXCEPT override |
Removes delivery filter for message type and subscriber. More... | |
virtual extraction_status_t | extract (demand_t &dest, duration_t empty_queue_timeout) override |
virtual bool | empty () const override |
Is message chain empty? More... | |
virtual std::size_t | size () const override |
Count of messages in the chain. More... | |
virtual void | close (close_mode_t mode) override |
Close the chain. More... | |
virtual environment_t & | environment () const override |
SObjectizer Environment for which the chain is created. More... | |
Protected Member Functions | |
virtual extraction_status_t | extract (demand_t &dest, select_case_t &select_case) override |
An extraction attempt as a part of multi chain select. More... | |
virtual void | remove_from_select (select_case_t &select_case) override |
Removement of mchain from multi chain select. More... | |
virtual void | do_deliver_message_from_timer (const std::type_index &msg_type, const message_ref_t &message) override |
Special method for message delivery from a timer thread. More... | |
![]() | |
atomic_refcounted_t (const atomic_refcounted_t &)=delete | |
atomic_refcounted_t & | operator= (const atomic_refcounted_t &)=delete |
atomic_refcounted_t () SO_5_NOEXCEPT | |
Default constructor. More... | |
~atomic_refcounted_t () SO_5_NOEXCEPT=default | |
Destructor. More... | |
void | inc_ref_count () SO_5_NOEXCEPT |
Increments reference count. More... | |
unsigned long | dec_ref_count () SO_5_NOEXCEPT |
Decrement reference count. More... | |
Private Member Functions | |
void | try_to_store_message_to_queue (const std::type_index &msg_type, const message_ref_t &message, invocation_type_t demand_type) |
Actual implementation of pushing message to the queue. More... | |
void | try_to_store_message_from_timer_to_queue (const std::type_index &msg_type, const message_ref_t &message, invocation_type_t demand_type) |
An implementation of storing another message to chain for the case of delated/periodic messages. More... | |
extraction_status_t | extract_demand_from_not_empty_queue (demand_t &dest) |
Implementation of extract operation for the case when message queue is not empty. More... | |
void | notify_multi_chain_select_ops () const SO_5_NOEXCEPT |
void | complete_store_message_to_queue (typename Tracing_Base::deliver_op_tracer &tracer, const std::type_index &msg_type, const message_ref_t &message, invocation_type_t demand_type) |
A reusable method with implementation of last part of storing a message into chain. More... | |
Private Attributes | |
environment_t & | m_env |
SObjectizer Environment for which message chain is created. More... | |
details::status | m_status = { details::status::open } |
Status of the chain. More... | |
const mbox_id_t | m_id |
Mbox ID for chain. More... | |
const capacity_t | m_capacity |
Chain capacity. More... | |
const not_empty_notification_func_t | m_not_empty_notificator |
Optional notificator for 'not_empty' condition. More... | |
Queue | m_queue |
Chain's demands queue. More... | |
std::mutex | m_lock |
Chain's lock. More... | |
std::condition_variable | m_underflow_cond |
Condition variable for waiting on empty queue. More... | |
std::condition_variable | m_overflow_cond |
Condition variable for waiting on full queue. More... | |
std::size_t | m_threads_to_wakeup = { 0 } |
Count of threads sleeping on empty mchain. More... | |
select_case_t * | m_select_tail = nullptr |
A queue of multi-chain selects in which this chain is used. More... | |
Additional Inherited Members |
Template-based implementation of message chain.
Queue | type of demand queue for message chain. |
Tracing_Base | type with message tracing implementation details. |
|
inline |
Initializing constructor.
env | SObjectizer Environment for which message chain is created. |
id | Mbox ID for this chain. |
params | Chain parameters. |
tracing_args | Arguments for Tracing_Base's constructor. |
|
inlineoverridevirtual |
Close the chain.
Implements so_5::abstract_message_chain_t.
|
inlineprivate |
A reusable method with implementation of last part of storing a message into chain.
|
inlineoverridevirtual |
Deliver enveloped message.
Reimplemented from so_5::abstract_message_box_t.
|
inlineoverridevirtual |
Deliver message for all subscribers with respect to message limits.
Implements so_5::abstract_message_box_t.
|
inlineoverrideprotectedvirtual |
Special method for message delivery from a timer thread.
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 that implementation of that method in abstract_message_box_t class is just a proxy for do_deliver_message() method. It is done to keep compatibility with previous versions of SObjectizer. The actual implementation of that method is present only in message chains.
Reimplemented from so_5::abstract_message_box_t.
|
inlineoverridevirtual |
Deliver service request.
Implements so_5::abstract_message_box_t.
|
inlineoverridevirtual |
Removes delivery filter for message type and subscriber.
Implements so_5::abstract_message_box_t.
|
inlineoverridevirtual |
Is message chain empty?
Implements so_5::abstract_message_chain_t.
|
inlineoverridevirtual |
SObjectizer Environment for which the chain is created.
Implements so_5::abstract_message_chain_t.
|
inlineoverridevirtual |
Implements so_5::abstract_message_chain_t.
|
inlineoverrideprotectedvirtual |
An extraction attempt as a part of multi chain select.
Reimplemented from so_5::abstract_message_chain_t.
|
inlineprivate |
Implementation of extract operation for the case when message queue is not empty.
|
inlineoverridevirtual |
|
inlineprivate |
|
inlineoverridevirtual |
Get the mbox name.
Implements so_5::abstract_message_box_t.
|
inlineoverrideprotectedvirtual |
Removement of mchain from multi chain select.
Reimplemented from so_5::abstract_message_chain_t.
|
inlineoverridevirtual |
Implements so_5::abstract_message_box_t.
|
inlineoverridevirtual |
Count of messages in the chain.
Implements so_5::abstract_message_chain_t.
|
inlineoverridevirtual |
Add the message handler.
Implements so_5::abstract_message_box_t.
|
inlineprivate |
An implementation of storing another message to chain for the case of delated/periodic messages.
This implementation handles overloaded chains differently:
These defferences are necessary because the context of timer thread is very special: there can't be any long-time operation (like waiting for free space on overloaded chain) and there can't be an exception about mchain's overflow.
|
inlineprivate |
Actual implementation of pushing message to the queue.
|
inlineoverridevirtual |
Get the type of message box.
Implements so_5::abstract_message_box_t.
|
inlineoverridevirtual |
Remove all message handlers.
Implements so_5::abstract_message_box_t.
|
private |
Chain capacity.
|
private |
SObjectizer Environment for which message chain is created.
|
private |
Mbox ID for chain.
|
mutableprivate |
Chain's lock.
|
private |
Optional notificator for 'not_empty' condition.
|
mutableprivate |
Condition variable for waiting on full queue.
|
mutableprivate |
Chain's demands queue.
|
mutableprivate |
A queue of multi-chain selects in which this chain is used.
|
private |
Status of the chain.
|
private |
Count of threads sleeping on empty mchain.
This value is incremented before sleeping on m_underflow_cond and decremented just after a return from this sleep.
|
mutableprivate |
Condition variable for waiting on empty queue.