|
SObjectizer 5.8
|
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. | |
| mbox_id_t | id () const override |
| Unique ID of this mbox. | |
| void | subscribe_event_handler (const std::type_index &, abstract_message_sink_t &) override |
| Add the message handler. | |
| void | unsubscribe_event_handler (const std::type_index &, abstract_message_sink_t &) 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) override |
| Deliver message for all subscribers with respect to message limits. | |
| void | set_delivery_filter (const std::type_index &, const delivery_filter_t &, abstract_message_sink_t &) override |
| void | drop_delivery_filter (const std::type_index &, abstract_message_sink_t &) noexcept override |
| Removes delivery filter for message type and subscriber. | |
| extraction_status_t | extract (demand_t &dest, duration_t empty_queue_timeout) override |
| bool | empty () const override |
| Is message chain empty? | |
| std::size_t | size () const override |
| Count of messages in the chain. | |
| environment_t & | environment () const noexcept override |
| SObjectizer Environment for which the mbox is created. | |
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. | |
| mchain_props::push_status_t | push (const std::type_index &msg_type, const message_ref_t &message, mchain_props::select_case_t &select_case) override |
| An attempt to push a new message into the mchain. | |
| void | remove_from_select (select_case_t &select_case) noexcept override |
| Removement of mchain from multi chain select. | |
| void | actual_close (close_mode_t mode) override |
| Close the chain. | |
Protected Member Functions inherited from so_5::atomic_refcounted_t | |
| atomic_refcounted_t (const atomic_refcounted_t &)=delete | |
| atomic_refcounted_t & | operator= (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. | |
Private Member Functions | |
| void | try_to_store_message_to_queue_ordinary_mode (const std::type_index &msg_type, const message_ref_t &message) |
| Actual implementation of pushing message to the queue. | |
| void | try_to_store_message_to_queue_nonblocking_mode (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. | |
| 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. | |
| 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. | |
Private Attributes | |
| environment_t & | m_env |
| SObjectizer Environment for which message chain is created. | |
| details::status | m_status = { details::status::open } |
| Status of the chain. | |
| const mbox_id_t | m_id |
| Mbox ID for chain. | |
| const capacity_t | m_capacity |
| Chain capacity. | |
| const not_empty_notification_func_t | m_not_empty_notificator |
| Optional notificator for 'not_empty' condition. | |
| Queue | m_queue |
| Chain's demands queue. | |
| std::mutex | m_lock |
| Chain's lock. | |
| std::condition_variable | m_underflow_cond |
| Condition variable for waiting on empty queue. | |
| std::condition_variable | m_overflow_cond |
| Condition variable for waiting on full queue. | |
| std::size_t | m_threads_to_wakeup = { 0 } |
| Count of threads sleeping on empty mchain. | |
| select_case_t * | m_select_tail = nullptr |
| A queue of multi-chain selects in which this chain is used. | |
Template-based implementation of message chain.
| Queue | type of demand queue for message chain. |
| Tracing_Base | type with message tracing implementation details. |
Definition at line 317 of file mchain_details.hpp.
|
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. |
Definition at line 324 of file mchain_details.hpp.
|
inlineoverrideprotectedvirtual |
Close the chain.
| mode | What to do with chain's content. |
Implements so_5::abstract_message_chain_t.
Definition at line 581 of file mchain_details.hpp.
|
inlineprivate |
A reusable method with implementation of last part of storing a message into chain.
Definition at line 894 of file mchain_details.hpp.
|
inlineoverridevirtual |
Deliver message for all subscribers with respect to message limits.
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.
| delivery_mode | Can the delivery blocks the current thread? |
| msg_type | Type of the message to deliver. |
| message | A message instance to be delivered. |
| redirection_deep | Current deep of overlimit reaction recursion. |
Implements so_5::abstract_message_box_t.
Definition at line 379 of file mchain_details.hpp.
|
inlineoverridevirtualnoexcept |
Removes delivery filter for message type and subscriber.
Implements so_5::abstract_message_box_t.
Definition at line 417 of file mchain_details.hpp.
|
inlineoverridevirtual |
Is message chain empty?
Implements so_5::abstract_message_chain_t.
Definition at line 472 of file mchain_details.hpp.
|
inlineoverridevirtualnoexcept |
SObjectizer Environment for which the mbox is created.
Reimplemented from so_5::abstract_message_chain_t.
Definition at line 484 of file mchain_details.hpp.
|
inlinenodiscardoverridevirtual |
Implements so_5::abstract_message_chain_t.
Definition at line 424 of file mchain_details.hpp.
|
inlinenodiscardoverrideprotectedvirtual |
An extraction attempt as a part of multi chain select.
| dest | Destination for extracted messages. |
| select_case | Select case to be stored for notification if mchain is empty. |
Implements so_5::abstract_message_chain_t.
Definition at line 492 of file mchain_details.hpp.
|
inlineprivate |
Implementation of extract operation for the case when message queue is not empty.
Definition at line 845 of file mchain_details.hpp.
|
inlineoverridevirtual |
Unique ID of this mbox.
Reimplemented from so_5::abstract_message_chain_t.
Definition at line 342 of file mchain_details.hpp.
|
inlineprivatenoexcept |
Definition at line 872 of file mchain_details.hpp.
|
inlinenodiscardoverrideprotectedvirtual |
An attempt to push a new message into the mchain.
Unlike do_deliver_message() method the push() doesn't apply the overload reaction if the mchain if full. The select_case is stored to select_cases list instead.
| msg_type | Type of message/signal to be pushed. |
| message | Message/signal to be pushed. |
| select_case | Select case to be stored for notification if mchain is full. |
Implements so_5::abstract_message_chain_t.
Definition at line 517 of file mchain_details.hpp.
|
inlineoverridevirtual |
Get the mbox name.
Implements so_5::abstract_message_box_t.
Definition at line 364 of file mchain_details.hpp.
|
inlineoverrideprotectedvirtualnoexcept |
Removement of mchain from multi chain select.
| select_case | Select case to be removed from notification queue. |
Implements so_5::abstract_message_chain_t.
Definition at line 555 of file mchain_details.hpp.
|
inlineoverridevirtual |
Implements so_5::abstract_message_box_t.
Definition at line 406 of file mchain_details.hpp.
|
inlineoverridevirtual |
Count of messages in the chain.
Implements so_5::abstract_message_chain_t.
Definition at line 478 of file mchain_details.hpp.
|
inlineoverridevirtual |
Add the message handler.
| type_index | Message type. |
| subscriber | Subscriber. |
Implements so_5::abstract_message_box_t.
Definition at line 348 of file mchain_details.hpp.
|
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.
Definition at line 777 of file mchain_details.hpp.
|
inlineprivate |
Actual implementation of pushing message to the queue.
Definition at line 671 of file mchain_details.hpp.
|
inlineoverridevirtual |
Get the type of message box.
Implements so_5::abstract_message_box_t.
Definition at line 373 of file mchain_details.hpp.
|
inlineoverridevirtualnoexcept |
Remove all message handlers.
| type_index | Message type. |
| subscriber | Subscriber. |
Implements so_5::abstract_message_box_t.
Definition at line 358 of file mchain_details.hpp.
|
private |
Chain capacity.
Definition at line 628 of file mchain_details.hpp.
|
private |
SObjectizer Environment for which message chain is created.
Definition at line 619 of file mchain_details.hpp.
|
private |
Mbox ID for chain.
Definition at line 625 of file mchain_details.hpp.
|
private |
Chain's lock.
Definition at line 637 of file mchain_details.hpp.
|
private |
Optional notificator for 'not_empty' condition.
Definition at line 631 of file mchain_details.hpp.
|
private |
Condition variable for waiting on full queue.
Definition at line 642 of file mchain_details.hpp.
|
private |
Chain's demands queue.
Definition at line 634 of file mchain_details.hpp.
|
private |
A queue of multi-chain selects in which this chain is used.
Definition at line 661 of file mchain_details.hpp.
|
private |
Status of the chain.
Definition at line 622 of file mchain_details.hpp.
|
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.
Definition at line 653 of file mchain_details.hpp.
|
private |
Condition variable for waiting on empty queue.
Definition at line 640 of file mchain_details.hpp.