v.5.8.2 - Stiffstream/sobjectizer GitHub Wiki
- Synchronous mode for wrapped_env_t constructor
- A new type of subscription storage: flat-set based
- A possibility to set "global" subscription storage factory
- Optional name for an agent
- A couple of new methods for so_5::stats::prefix_t and so_5::stats::suffix_t
Version 5.8.2 allows to wait completion of init-function in the constructor of so_5::wrapped_env_t
. This is called synchronous-mode.
so_5::mbox_t target_mbox;
so_5::wrapped_env_t sobjectizer{
so_5::wrapped_env_t::wait_init_completion,
[&](so_5::environment_t & env) {
env.introduce_coop([&](so_5::coop_t & coop) {
target_mbox = coop.make_agent<my_agent>(...)->so_direct_mbox(); // (1)
});
}
};
so_5::send<my_message>(target_mbox, ...); // (2)
It's now guaranteed that code at point (1) completes before the execution of the code at point (2).
There is also a new section in the Wiki that provides more details about this feature.
SObjectizer supports several type of containers for holding agents subscriptions: one is based on unsorted vector, another uses std::map, yet another uses std::unordered_map. There is also a combined type: one container is for small number of subscriptions and another for a big number.
Version 5.8.2 adds another type: it uses a vector with ordered items (aka flat-set) and binary search for manipulation with subscriptions. This type of subscription storage may be more effective that map- or unordered_map-based storages in some cases.
The new type of subscription storage can be specified via a new so_5::flat_set_based_subscription_storage_factory()
function.
There is also a new section in the Wiki that describes subscription storages.
There is a new default_subscription_storage_factory()
method in so_5::environment_params_t
class. This method allows to specify a factory for subscription storage to be used by default:
so_5::launch( [](so_5::environment_t & env) {...},
[](so_5::environment_params_t & params) {
params.default_subscription_storage_factory(
so_5::flat_set_based_subscription_storage_factory(32u) );
} );
Version 5.8.2 adds a possibility to set a name for an agent:
class my_agent final : public so_5::agent_t
{
public:
my_agent(context_t ctx, std::string_view name)
: so_5::agent_t{ ctx + name_for_agent(name) }
{}
...
};
This name can be obtained via a new so_5::agent_t::so_agent_name()
method.
There is also a new section in the Wiki that describes optional agent names in more details.
Methods as_string_view()
have been added to so_5::stats::prefix_t
and so_5::stats::suffix_t
classes.