SObjectizer  5.8
Loading...
Searching...
No Matches
so-5.5.16: create_mchain helper functions

Several new helper functions so_5::create_mchain have been added in v.5.5.16. They simplify creation of mchains.

For example, creation of size-unlimited mchain can looks like:

so_5::environment_t & env = ...;
auto ch = create_mchain( env );
SObjectizer Environment.

instead of:

so_5::environment_t & env = ...;
mchain_t create_mchain(const mchain_params_t &params)
Create message chain.
mchain_params_t make_unlimited_mchain_params()
Create parameters for size-unlimited mchain.
Definition mchain.hpp:860

There are also create_mchain functions for creation of size-limited mchains (with or without waiting on overflow):

so_5::environment_t & env = ...;
// Creation of size-limited mchain without waiting on overflow.
auto ch1 = create_mchain( env,
// No more than 200 messages in the chain.
200,
// Memory will be allocated dynamically.
// New messages will be ignored on chain's overflow.
// Creation of size-limited mchain with waiting on overflow.
auto ch2 = create_mchain( env,
// Wait for 150ms.
std::chrono::milliseconds{150},
// No more than 200 messages in the chain.
200,
// Memory will be allocated dynamically.
// New messages will be ignored on chain's overflow.
@ drop_newest
New message must be ignored and droped.
@ dynamic
Storage can be allocated and deallocated dynamically.

Please note that the first argument for create_mchain function can be a reference to environment_t or to wrapped_env_t object. It allows to write:

auto ch = create_mchain(sobj);
A wrapped environment.

instead of:

auto ch = create_mchain(sobj.environment());