SObjectizer  5.5
Public Member Functions | Protected Member Functions | Private 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::actual_select_case_t< N >

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
 
select_case_tgiveout_next ()
 
void set_next (select_case_t *next)
 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...
 
mchain_receive_result_t try_receive (select_notificator_t &notificator)
 An attempt to extract and handle a message from mchain. More...
 
const mchain_tchain () const noexcept
 Get the underlying mchain. More...
 

Protected Member Functions

virtual mchain_receive_result_t try_handle_extracted_message (demand_t &demand)=0
 Attempt to handle extracted message. More...
 

Private 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

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

◆ giveout_next()

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

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.

◆ query_next()

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

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)
inline

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

See also
select_case_t::m_next.

◆ try_handle_extracted_message()

virtual mchain_receive_result_t so_5::mchain_props::select_case_t::try_handle_extracted_message ( demand_t demand)
protectedpure virtual

Attempt to handle extracted message.

This method will be overriden in derived classes.

Implemented in so_5::mchain_props::details::actual_select_case_t< N >.

◆ try_receive()

mchain_receive_result_t so_5::mchain_props::select_case_t::try_receive ( select_notificator_t notificator)
inline

An attempt to extract and handle a message from mchain.

Note
This method returns immediately if mchain is empty. In this case select_case object will stay in select_case queue inside mchain.

Member Data Documentation

◆ m_chain

mchain_t so_5::mchain_props::select_case_t::m_chain
private

Message chain to receive message from.

◆ m_next

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

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
private

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_receive() where m_notificator receives an actual pointer (m_notificator can become nullptr again in try_receive() if mchain has messages or was closed);
  • on_select_finish() where m_notificator receives nullptr value if it wasn't null yet.

It 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: