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... | |
mbox_id_t | id () const override |
Unique ID of this mbox. More... | |
void | subscribe_event_handler (const std::type_index &, const so_5::message_limit::control_block_t *, agent_t &) override |
Add the message handler. More... | |
void | unsubscribe_event_handlers (const std::type_index &, agent_t &) override |
Remove all message handlers. More... | |
std::string | query_name () const override |
Get the mbox name. More... | |
mbox_type_t | type () const override |
Get the type of message box. More... | |
void | do_deliver_message (const std::type_index &msg_type, const message_ref_t &message, unsigned int) override |
Deliver message for all subscribers with respect to message limits. More... | |
void | set_delivery_filter (const std::type_index &, const delivery_filter_t &, agent_t &) override |
void | drop_delivery_filter (const std::type_index &, agent_t &) noexcept override |
Removes delivery filter for message type and subscriber. More... | |
extraction_status_t | extract (demand_t &dest, duration_t empty_queue_timeout) override |
bool | empty () const override |
Is message chain empty? More... | |
std::size_t | size () const override |
Count of messages in the chain. More... | |
void | close (close_mode_t mode) override |
Close the chain. More... | |
environment_t & | environment () const noexcept override |
SObjectizer Environment for which the mbox is created. More... | |
Protected Member Functions | |
extraction_status_t | extract (demand_t &dest, select_case_t &select_case) override |
An extraction attempt as a part of multi chain select. More... | |
void | remove_from_select (select_case_t &select_case) override |
Removement of mchain from multi chain select. More... | |
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 () noexcept | |
Default constructor. More... | |
~atomic_refcounted_t () noexcept=default | |
Destructor. More... | |
void | inc_ref_count () noexcept |
Increments reference count. More... | |
unsigned long | dec_ref_count () 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) |
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) |
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 () 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) |
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 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.
|
inlineoverridevirtualnoexcept |
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.
|
inlineoverridevirtualnoexcept |
SObjectizer Environment for which the mbox is created.
Implements so_5::abstract_message_box_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 |
|
inlineprivatenoexcept |
|
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.
|
private |
Chain's lock.
|
private |
Optional notificator for 'not_empty' condition.
|
private |
Condition variable for waiting on full queue.
|
private |
Chain's demands queue.
|
private |
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.
|
private |
Condition variable for waiting on empty queue.