SObjectizer 5.8
Loading...
Searching...
No Matches
so_5::prepared_select_t< Cases_Count > Class Template Reference

Special container for holding select parameters and select cases. More...

#include <mchain_select.hpp>

Public Member Functions

 prepared_select_t (const prepared_select_t &)=delete
 
prepared_select_toperator= (const prepared_select_t &)=delete
 
 prepared_select_t (prepared_select_t &&other) noexcept
 Move constructor.
 
prepared_select_toperator= (prepared_select_t &&other) noexcept
 Move operator.
 
bool empty () const noexcept
 Is this handle empty?
 
Getters
auto & data () const noexcept
 

Private Member Functions

template<typename... Cases>
 prepared_select_t (mchain_select_params_t< mchain_props::msg_count_status_t::defined > params, Cases &&... cases)
 Initializing constructor.
 

Private Attributes

std::unique_ptr< mchain_props::details::prepared_select_data_t< Cases_Count > > m_data
 The actual prepared-select object.
 

Friends

template<mchain_props::msg_count_status_t Msg_Count_Status, typename... Cases>
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.
 
void swap (prepared_select_t &a, prepared_select_t &b) noexcept
 Swap operation.
 

Detailed Description

template<std::size_t Cases_Count>
class so_5::prepared_select_t< Cases_Count >

Special container for holding select parameters and select cases.

Note
Instances of that type usually used without specifying the actual type:
auto prepared = so_5::prepare_select(
so_5::from_all().handle_n(10).empty_timeout(10s),
receive_case( ch1, some_handlers... ),
receive_case( ch2, more_handlers... ), ... );
...
auto r = so_5::select( prepared );
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 > &params, Cases &&... cases)
An advanced form of multi chain select.
mchain_props::select_case_unique_ptr_t receive_case(mchain_t chain, Handlers &&... handlers)
A helper for creation of select_case object for one 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.
This is a moveable type, not copyable. It is very like to unique_ptr. Because of that an instance of prepared_select_t can empty. It means that the actual content (e.g. prepared-select object) was moved to another prepared_select_t instance. Usage of empty prepared_select_t is an error and can lead to null-pointer dereference. SObjectizer doesn't check the emptiness of prepared_select_t object.
Since
v.5.5.17

Definition at line 1740 of file mchain_select.hpp.

Constructor & Destructor Documentation

◆ prepared_select_t() [1/3]

template<std::size_t Cases_Count>
template<typename... Cases>
so_5::prepared_select_t< Cases_Count >::prepared_select_t ( mchain_select_params_t< mchain_props::msg_count_status_t::defined > params,
Cases &&... cases )
inlineprivate

Initializing constructor.

Note
This constructor is private since v.5.6.1

Definition at line 1768 of file mchain_select.hpp.

◆ prepared_select_t() [2/3]

template<std::size_t Cases_Count>
so_5::prepared_select_t< Cases_Count >::prepared_select_t ( const prepared_select_t< Cases_Count > & )
delete

◆ prepared_select_t() [3/3]

template<std::size_t Cases_Count>
so_5::prepared_select_t< Cases_Count >::prepared_select_t ( prepared_select_t< Cases_Count > && other)
inlinenoexcept

Move constructor.

Definition at line 1785 of file mchain_select.hpp.

Member Function Documentation

◆ data()

template<std::size_t Cases_Count>
auto & so_5::prepared_select_t< Cases_Count >::data ( ) const
inlinenoexcept

Definition at line 1819 of file mchain_select.hpp.

◆ empty()

template<std::size_t Cases_Count>
bool so_5::prepared_select_t< Cases_Count >::empty ( ) const
inlinenoexcept

Is this handle empty?

Since
v.5.6.1

Definition at line 1812 of file mchain_select.hpp.

◆ operator=() [1/2]

template<std::size_t Cases_Count>
prepared_select_t & so_5::prepared_select_t< Cases_Count >::operator= ( const prepared_select_t< Cases_Count > & )
delete

◆ operator=() [2/2]

template<std::size_t Cases_Count>
prepared_select_t & so_5::prepared_select_t< Cases_Count >::operator= ( prepared_select_t< Cases_Count > && other)
inlinenoexcept

Move operator.

Definition at line 1792 of file mchain_select.hpp.

Friends And Related Symbol Documentation

◆ prepare_select

template<std::size_t Cases_Count>
template<mchain_props::msg_count_status_t Msg_Count_Status, typename... Cases>
prepared_select_t< sizeof...(Cases) > prepare_select ( mchain_select_params_t< Msg_Count_Status > params,
Cases &&... cases )
friend

Create prepared select statement to be used later.

Attention
Since v.5.6.0 at least handle_all(), handle_n() or extract_n() should be called before passing result of from_all() to prepare_select() function.

Accepts all parameters as advanced select() version. For example:

// Receive and handle 3 messages.
// If there is no 3 messages in chains the select will wait
// no more that 200ms.
// A return from select will be after handling of 3 messages or
// if all mchains are closed explicitely, or if there is no messages
// for more than 200ms.
auto prepared1 = prepare_select(
so_5::from_all().handle_n( 3 ).empty_timeout( milliseconds(200) ),
[]( const first_message_type & msg ) { ... },
[]( const second_message_type & msg ) { ... } ),
[]( const third_message_type & msg ) { ... },
handler< some_signal_type >( []{ ... ] ),
... ) );
// Receive all messages from mchains.
// If there is no message in any of mchains then wait no more than 500ms.
// A return from select will be after explicit close of all mchains
// or if there is no messages for more than 500ms.
auto prepared2 = prepare_select(
so_5::from_all().handle_all().empty_timeout( milliseconds(500) ),
[]( const first_message_type & msg ) { ... },
[]( const second_message_type & msg ) { ... } ),
[]( const third_message_type & msg ) { ... },
handler< some_signal_type >( []{ ... ] ),
... ) );
friend 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.
Note
Since v.5.8.4 the value of empty_timeout (or no_wait_on_empty) is taken into account when total_time is specified. It means that in the following example the select() returns immediately if all mchains are empty:
auto prepared = prepare_select(
from_all().handle_n(5).no_wait_on_empty().total_time(6s),
receive_case( ch1, ...),
receive_case( ch2, ...) );
...
so_5::select(prepared);
Since
v.5.5.17
Parameters
paramsParameters for advanced select.
casesSelect cases.

Definition at line 1888 of file mchain_select.hpp.

◆ swap

template<std::size_t Cases_Count>
void swap ( prepared_select_t< Cases_Count > & a,
prepared_select_t< Cases_Count > & b )
friend

Swap operation.

Definition at line 1801 of file mchain_select.hpp.

Member Data Documentation

◆ m_data

template<std::size_t Cases_Count>
std::unique_ptr< mchain_props::details::prepared_select_data_t<Cases_Count> > so_5::prepared_select_t< Cases_Count >::m_data
private

The actual prepared-select object.

Note
Can be null if the actual content was moved to another prepared_select_t instance.
Since
v.5.6.1

Definition at line 1760 of file mchain_select.hpp.


The documentation for this class was generated from the following file: