SObjectizer  5.8
Loading...
Searching...
No Matches
so_5::mchain_master_handle_t Class Reference

Helper class for automatic close of a mchain at the destruction of master handle instance. More...

#include <mchain_helper_functions.hpp>

Public Member Functions

 mchain_master_handle_t (const mchain_master_handle_t &)=delete
 
mchain_master_handle_toperator= (const mchain_master_handle_t &)=delete
 
 mchain_master_handle_t (mchain_t chain, mchain_props::close_mode_t close_mode) noexcept
 Initializing constructor.
 
 mchain_master_handle_t (mchain_master_handle_t &&handle) noexcept
 Move constructor.
 
 ~mchain_master_handle_t ()
 Destructor closes the chain.
 
mchain_master_handle_toperator= (mchain_master_handle_t &&handle) noexcept
 Move operator.
 
const mchain_tget () const noexcept
 Get the mchain.
 
const mchain_toperator* () const noexcept
 Get the mchain.
 

Static Public Member Functions

Helpers methods for master handle creation.
static mchain_master_handle_t make (mchain_t chain, mchain_props::close_mode_t close_mode) noexcept
 
static mchain_master_handle_t with_drop_content (mchain_t chain) noexcept
 
static mchain_master_handle_t with_retain_content (mchain_t chain) noexcept
 

Private Attributes

mchain_t m_chain
 Chain to be hold.
 
mchain_props::close_mode_t m_close_mode
 Close mode for mchain.
 

Friends

void swap (mchain_master_handle_t &a, mchain_master_handle_t &b) noexcept
 Swap operation.
 

Detailed Description

Helper class for automatic close of a mchain at the destruction of master handle instance.

This class is intended for cases like that:

auto ch = so_5::create_mchain( env );
auto ch_closer = so_5::auto_close_drop_content( ch );
...
mchain_auto_close_details::auto_closer_t< sizeof...(Tail) > auto_close_drop_content(Tail &&... tail)
Helper function for automatic closing of mchains with dropping their content.
mchain_t create_mchain(environment_t &env)
Create size-unlimited chain.

The example shown above can be replaced by:

// Or
// Or
Helper class for automatic close of a mchain at the destruction of master handle instance.
static mchain_master_handle_t make(mchain_t chain, mchain_props::close_mode_t close_mode) noexcept
static mchain_master_handle_t with_drop_content(mchain_t chain) noexcept
@ drop_content
All messages must be removed from chain.
Attention
Since v.5.7.3 it uses so_5::terminate_if_throws calling 'close' for mchains.
Note
This class is moveable but not copyable.
Since
v.5.5.17

Definition at line 514 of file mchain_helper_functions.hpp.

Constructor & Destructor Documentation

◆ mchain_master_handle_t() [1/3]

so_5::mchain_master_handle_t::mchain_master_handle_t ( const mchain_master_handle_t & )
delete

◆ mchain_master_handle_t() [2/3]

so_5::mchain_master_handle_t::mchain_master_handle_t ( mchain_t chain,
mchain_props::close_mode_t close_mode )
inlinenoexcept

Initializing constructor.

Parameters
chainA mchain itself.
close_modeClose mode for mchain.

Definition at line 522 of file mchain_helper_functions.hpp.

◆ mchain_master_handle_t() [3/3]

so_5::mchain_master_handle_t::mchain_master_handle_t ( mchain_master_handle_t && handle)
inlinenoexcept

Move constructor.

Definition at line 532 of file mchain_helper_functions.hpp.

◆ ~mchain_master_handle_t()

so_5::mchain_master_handle_t::~mchain_master_handle_t ( )
inline

Destructor closes the chain.

Definition at line 539 of file mchain_helper_functions.hpp.

Member Function Documentation

◆ get()

const mchain_t & so_5::mchain_master_handle_t::get ( ) const
inlinenoexcept

Get the mchain.

Definition at line 566 of file mchain_helper_functions.hpp.

◆ make()

static mchain_master_handle_t so_5::mchain_master_handle_t::make ( mchain_t chain,
mchain_props::close_mode_t close_mode )
inlinestaticnoexcept
Usage example:
void demo( so_5::environment_t & env, app_config & config )
{
std::thread worker;
auto worker_joiner = so_5::auto_join( worker );
create_mchain( env ),
detect_close_mode( config ) );
worker = std::thread( [ch = *chain]{ ... } );
...
}
SObjectizer Environment.
thread_auto_join_details::auto_joiner_t< 1+sizeof...(Tail) > auto_join(std::thread &first_thread, Tail &&... tail)
Helper function for creation of automatic joiner of std::threads.

Definition at line 592 of file mchain_helper_functions.hpp.

◆ operator*()

const mchain_t & so_5::mchain_master_handle_t::operator* ( ) const
inlinenoexcept

Get the mchain.

Definition at line 570 of file mchain_helper_functions.hpp.

◆ operator=() [1/2]

mchain_master_handle_t & so_5::mchain_master_handle_t::operator= ( const mchain_master_handle_t & )
delete

◆ operator=() [2/2]

mchain_master_handle_t & so_5::mchain_master_handle_t::operator= ( mchain_master_handle_t && handle)
inlinenoexcept

Move operator.

Definition at line 547 of file mchain_helper_functions.hpp.

◆ with_drop_content()

static mchain_master_handle_t so_5::mchain_master_handle_t::with_drop_content ( mchain_t chain)
inlinestaticnoexcept
Usage example:
void demo( so_5::environment_t & env )
{
std::thread worker;
auto worker_joiner = so_5::auto_join( worker );
create_mchain( env ) );
worker = std::thread( [ch = *chain]{ ... } );
...
}

Definition at line 616 of file mchain_helper_functions.hpp.

◆ with_retain_content()

static mchain_master_handle_t so_5::mchain_master_handle_t::with_retain_content ( mchain_t chain)
inlinestaticnoexcept
Usage example:
void demo( so_5::environment_t & env )
{
std::thread worker;
auto worker_joiner = so_5::auto_join( worker );
create_mchain( env ) );
worker = std::thread( [ch = *chain]{ ... } );
...
}
static mchain_master_handle_t with_retain_content(mchain_t chain) noexcept

Definition at line 639 of file mchain_helper_functions.hpp.

Friends And Related Symbol Documentation

◆ swap

void swap ( mchain_master_handle_t & a,
mchain_master_handle_t & b )
friend

Swap operation.

Definition at line 556 of file mchain_helper_functions.hpp.

Member Data Documentation

◆ m_chain

mchain_t so_5::mchain_master_handle_t::m_chain
private

Chain to be hold.

Definition at line 647 of file mchain_helper_functions.hpp.

◆ m_close_mode

mchain_props::close_mode_t so_5::mchain_master_handle_t::m_close_mode
private

Close mode for mchain.

Definition at line 649 of file mchain_helper_functions.hpp.


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