Usage of ordinary forms of so_5::receive functions inside loops could be inefficient because of wasting resources on constructions of internal objects with descriptions of handlers on each receive() call. More efficient way is the preparation of all receive params and reusing them later. A combination of so_5::prepare_receive() and so_5::receive() allows us to do that.
Usage example:
so_5::from(ch).extract_n(10).empty_timeout(200ms),
some_handlers... );
...
while( !some_condition )
{
...
}
mchain_receive_params_t< mchain_props::msg_count_status_t::undefined > from(mchain_t chain)
A helper function for simplification of creation of mchain_receive_params instance.
prepared_receive_t< sizeof...(Handlers) > prepare_receive(const mchain_receive_params_t< Msg_Count_Status > ¶ms, Handlers &&... handlers)
Create parameters for receive function to be used later.
mchain_receive_result_t receive(const mchain_receive_params_t< Msg_Count_Status > ¶ms, Handlers &&... handlers)
Advanced version of receive from mchain.
The exactly same situation is for so_5::select functions: some resources are allocated on each call of ordinary so_5::select() function and deallocated at exit. This reallocation can be avoided by using so_5::prepare_select() and appropriate so_5::select() function:
case_( ch1, some_handlers... ),
case_( ch2, more_handlers... ),
case_( ch3, yet_more_handlers... ) );
...
while( !some_condition )
{
...
}
mchain_select_params_t< mchain_props::msg_count_status_t::undefined > from_all()
Helper function for creation of mchain_select_params instance with default values.
mchain_select_result_t select(const mchain_select_params_t< Msg_Count_Status > ¶ms, Cases &&... cases)
An advanced form of multi chain select.
prepared_select_t< sizeof...(Cases) > prepare_select(mchain_select_params_t< Msg_Count_Status > params, Cases &&... cases)
Create prepared select statement to be used later.