Stiffstream / sobjectizer

An implementation of Actor, Publish-Subscribe, and CSP models in one rather small C++ framework. With performance, quality, and stability proved by years in the production.

Home Page:https://stiffstream.com/en/products/sobjectizer.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[idea] Support of delivery filters for MPSC mboxes?

eao197 opened this issue · comments

The current version of SObjectizer prohibits the usage of delivery filters with MPSC mboxes. The root of this ban is somewhere in the past. MPSC mboxes were created as an optimization trick to speed up message exchange in 1-to-1 scenarios. Mutable messages and the role of MPSC mboxes for mutable messages were discovered much later.

There is no big sense in support for delivery filters for standard MPSC mboxes (available via agent_t::so_direct_mbox()). But there can be some forms of custom MPSC mboxes (like unique-subscribers mboxes from upcoming so5extra-1.5), and the support for delivery filters for those custom mboxes could be crucial.

The problem is that the current version of SObjectizer doesn't provide a way to specify a delivery filter for a mutable message. Message mutability isn't supported by agent_t::so_set_delivery_filter methods.

An obvious solution is support for delivery_filters with a format:

bool filter(so_5::mutable_msg<T> msg);
// and, for symmetry
bool filter(so_5::immutable_msg<T> msg);

But the problem is that so_5::mutable_msg<T> and so_5::immutable_msg<T> are empty types.

Another solution is addition of some flag to agent_t::so_set_delivery_filter:

so_set_delivery_filter(so_5::message_mutability_t::mutable_message,
  [](const my_message & msg) { return msg.m_some_value < 10; });

Another solution is addition of a new method:

so_set_delivery_filter_for_mutable_msg(mbox,
  [](const my_message & msg) { return msg.m_some_value < 10; });

Is available now in v.5.7.4.