SObjectizer 5.8
Loading...
Searching...
No Matches
so_5::mchain_props::select_case_t Class Referenceabstract

Base class for representation of one case in multi chain select. More...

#include <mchain_select_ifaces.hpp>

Inheritance diagram for so_5::mchain_props::select_case_t:
so_5::mchain_props::details::receive_select_case_t so_5::mchain_props::details::send_select_case_t so_5::mchain_props::details::actual_receive_select_case_t< N > so_5::mchain_props::details::actual_send_select_case_t< On_Success_Handler >

Public Types

using handling_result_t
 The result of attempt of handling this case.
 

Public Member Functions

 select_case_t (mchain_t chain)
 Initialized constructor.
 
 select_case_t (const select_case_t &)=delete
 
 select_case_t (select_case_t &&)=delete
 
virtual ~select_case_t ()
 
select_case_tquery_next () const noexcept
 
select_case_tgiveout_next () noexcept
 
void set_next (select_case_t *next) noexcept
 Set the next item in the current queue to which select_case belongs.
 
void notify () noexcept
 Notification for all waiting select_cases.
 
void on_select_finish () noexcept
 Reaction to the end of select work.
 
virtual handling_result_t try_handle (select_notificator_t &notificator)=0
 An attempt to handle this case.
 
const mchain_tchain () const noexcept
 Get the underlying mchain.
 

Protected Member Functions

auto extract (demand_t &demand)
 Helper method for calling extract method of the target mchain.
 
auto push (const std::type_index &msg_type, const message_ref_t &message)
 Helper method for calling push method of the target mchain.
 

Protected Attributes

mchain_t m_chain
 Message chain to receive message from.
 
select_notificator_tm_notificator = nullptr
 Notificator to be used for notify sleeping thread.
 
select_case_tm_next = nullptr
 Next select_case in queue.
 

Detailed Description

Base class for representation of one case in multi chain select.

Attention
Objects of this class are not copyable nor moveable.
Since
v.5.5.16

Definition at line 64 of file mchain_select_ifaces.hpp.

Member Typedef Documentation

◆ handling_result_t

Initial value:
std::variant<
A result of receive from mchain.
Definition mchain.hpp:922
A result of attempt of sending messages to a message chain.
Definition mchain.hpp:979

The result of attempt of handling this case.

Definition at line 149 of file mchain_select_ifaces.hpp.

Constructor & Destructor Documentation

◆ select_case_t() [1/3]

so_5::mchain_props::select_case_t::select_case_t ( mchain_t chain)
inline

Initialized constructor.

Parameters
chainMessage chain for that this select_case is created.

Definition at line 154 of file mchain_select_ifaces.hpp.

◆ select_case_t() [2/3]

so_5::mchain_props::select_case_t::select_case_t ( const select_case_t & )
delete

◆ select_case_t() [3/3]

so_5::mchain_props::select_case_t::select_case_t ( select_case_t && )
delete

◆ ~select_case_t()

virtual so_5::mchain_props::select_case_t::~select_case_t ( )
inlinevirtual

Definition at line 163 of file mchain_select_ifaces.hpp.

Member Function Documentation

◆ chain()

const mchain_t & so_5::mchain_props::select_case_t::chain ( ) const
inlinenodiscardnoexcept

Get the underlying mchain.

Since
v.5.5.17

Definition at line 258 of file mchain_select_ifaces.hpp.

◆ extract()

auto so_5::mchain_props::select_case_t::extract ( demand_t & demand)
inlinenodiscardprotected

Helper method for calling extract method of the target mchain.

This method is intended to be called by a derived class. This helper is necessary because only select_case_t class is declared as friend for abstract_message_chain_t class. Classes that are derived from select_case_t are not friends for abstract_message_chain_t class and can't call protected/private methods of abstract_message_chain_t.

Since
v.5.7.0

Definition at line 118 of file mchain_select_ifaces.hpp.

◆ giveout_next()

select_case_t * so_5::mchain_props::select_case_t::giveout_next ( )
inlinenodiscardnoexcept

Get the next item in the current queue to which select_case belongs at this moment and drop this pointer to nullptr value.

This method must be used if select_case object must be extracted from the current queue.

See also
select_case_t::m_next.

Definition at line 187 of file mchain_select_ifaces.hpp.

◆ notify()

void so_5::mchain_props::select_case_t::notify ( )
inlinenoexcept

Notification for all waiting select_cases.

This method is called by mchain if empty mchain becomes non-empty or if it is closed.

This method does notification for all members of select_case queue. It means that mchain calls notify() for the head of the queue and that head does notification for all other queue's members.

Definition at line 214 of file mchain_select_ifaces.hpp.

◆ on_select_finish()

void so_5::mchain_props::select_case_t::on_select_finish ( )
inlinenoexcept

Reaction to the end of select work.

Attention
This method must be called before return from select() function to ensure that mchain do not hold a pointer to non-existent select_case object.
This method must not throw because it will be called from destructor of RAII wrappers.

Definition at line 237 of file mchain_select_ifaces.hpp.

◆ push()

auto so_5::mchain_props::select_case_t::push ( const std::type_index & msg_type,
const message_ref_t & message )
inlinenodiscardprotected

Helper method for calling push method of the target mchain.

This method is intended to be called by a derived class. This helper is necessary because only select_case_t class is declared as friend for abstract_message_chain_t class. Classes that are derived from select_case_t are not friends for abstract_message_chain_t class and can't call protected/private methods of abstract_message_chain_t.

Since
v.5.7.0
Parameters
msg_typeType of message/signal to be pushed.
messageMessage/signal to be pushed.

Definition at line 138 of file mchain_select_ifaces.hpp.

◆ query_next()

select_case_t * so_5::mchain_props::select_case_t::query_next ( ) const
inlinenodiscardnoexcept

Simple access to next item in the current queue to which select_case object belongs at this moment.

See also
select_case_t::m_next

Definition at line 172 of file mchain_select_ifaces.hpp.

◆ set_next()

void so_5::mchain_props::select_case_t::set_next ( select_case_t * next)
inlinenoexcept

Set the next item in the current queue to which select_case belongs.

See also
select_case_t::m_next.

Definition at line 199 of file mchain_select_ifaces.hpp.

◆ try_handle()

virtual handling_result_t so_5::mchain_props::select_case_t::try_handle ( select_notificator_t & notificator)
nodiscardpure virtual

Member Data Documentation

◆ m_chain

mchain_t so_5::mchain_props::select_case_t::m_chain
protected

Message chain to receive message from.

Definition at line 68 of file mchain_select_ifaces.hpp.

◆ m_next

select_case_t* so_5::mchain_props::select_case_t::m_next = nullptr
protected

Next select_case in queue.

A select_case object can be included in one of two different queues:

  • in select queue inside mchain (in this case m_notificator is not nullptr). Next item in queue belongs to different select(). This item must be notified in notify() method.
  • in ready to use select_case queue. The select_case is added to that queue when select_case in notified by mchain. The next item in queue belongs to the same select().

Definition at line 101 of file mchain_select_ifaces.hpp.

◆ m_notificator

select_notificator_t* so_5::mchain_props::select_case_t::m_notificator = nullptr
protected

Notificator to be used for notify sleeping thread.

Can be null. It means that select_case is not used in select queue for the mchain at that moment.

There are just two methods where m_notificator changes its value:

  • try_handle() where m_notificator receives an actual pointer (m_notificator can become nullptr again in try_handle() if mchain has messages or was closed);
  • on_select_finish() where m_notificator receives nullptr value if it wasn't null yet.

In the previous versions of SObjectizer m_notificator received nullptr value during notification of new messages arrival or closing of mchain. But this lead to data races and the behaviour was changed. Now m_notificator can hold an actual pointer even after notification was initiated.

Definition at line 89 of file mchain_select_ifaces.hpp.


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