SObjectizer  5.7
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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 = std::variant< so_5::mchain_receive_result_t, so_5::mchain_send_result_t >
 The result of attempt of handling this case. More...
 

Public Member Functions

 select_case_t (mchain_t chain)
 Initialized constructor. More...
 
 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. More...
 
void notify () noexcept
 Notification for all waiting select_cases. More...
 
void on_select_finish () noexcept
 Reaction to the end of select work. More...
 
virtual handling_result_t try_handle (select_notificator_t &notificator)=0
 An attempt to handle this case. More...
 
const mchain_tchain () const noexcept
 Get the underlying mchain. More...
 

Protected Member Functions

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

Protected Attributes

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

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

Member Typedef Documentation

◆ handling_result_t

The result of attempt of handling this case.

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.

◆ 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

Member Function Documentation

◆ chain()

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

Get the underlying mchain.

Since
v.5.5.17

◆ extract()

auto so_5::mchain_props::select_case_t::extract ( demand_t demand)
inlineprotected

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

◆ giveout_next()

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

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.

◆ 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.

◆ 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.

◆ push()

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

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.

◆ query_next()

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

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

◆ 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.

◆ try_handle()

virtual handling_result_t so_5::mchain_props::select_case_t::try_handle ( select_notificator_t notificator)
pure virtual

Member Data Documentation

◆ m_chain

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

Message chain to receive message from.

◆ 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().

◆ 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.


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