Interface for message sink.
This class is the base for all message sinks.
The purpose of message sink is to be a subscriber for an mbox. An mbox holds a list of subscribers and delivers a message to appropriate subscribers (message sinks). When an mbox receives a message it calls push_event() method for all message sinks that are subscribed to this message (and delivery filters permit the delivery to those sinks).
- Note
- A message sink in SO-5.8 plays the same role as agent_t in previous versions, in the sense that message sinks act as a receiver of messages sent to message boxes. Since an agent_t has priority and this priority is taken into account during subscriptions and message delivery, the message sink should also have priority. Because of that there is sink_priority() method. For cases where a message sink is created for an agent, the sink_priority() should return the agent's priority.
- Since
- v.5.8.0
- Examples
- so_5/custom_direct_mbox/main.cpp.
Definition at line 69 of file message_sink.hpp.
Get a message and push it to the appropriate destination.
This is key method for message sink. Its logic depends of message sink type. For example, ordinary message sink for an agent just pushes the message to the agent's event_queue.
- Attention
- Implementations of message sinks should control the value of redirection_deep. If that value exceeds so_5::max_redirection_deep then the delivery procedure has to be cancelled and the message (signal) should be dropped (ignored). If an implementation redirects message to another mbox/msink then the value of redirection_deep has to be incremented.
-
The tracer can be nullptr. Moreover, it will be nullptr in most of the cases when message delivery tracing is off.
- Parameters
-
| mbox_id | ID of mbox from that the message is received. |
| delivery_mode | Delivery mode for this delivery attempt. |
| msg_type | Type of message to be delivered. |
| message | Reference to the message to be delivered. NOTE: it can be empty (nullptr) reference in the case of a signal. |
| redirection_deep | The current deep of message redirection between mboxes and msinks. |
| tracer | Message delivery tracer to be used inside overlimit reaction. NOTE: it will be nullptr when message delivery tracing if off. |
Implemented in so_5::as_msink_impl::mbox_as_sink_t, so_5::impl::message_sink_with_message_limit_t, so_5::impl::message_sink_without_message_limit_t, and so_5::msinks::transform_then_redirect_impl::basic_transform_then_redirect_sink_t< Transformer >.