#include <iostream>
#include <sstream>
{
public :
a_child_t(
context_t ctx,
int generation,
int max_generation )
, m_coordinator( std::move( coordinator ) )
, m_generation( generation )
, m_max_generation( max_generation )
{}
{
send_hello_to_coordinator();
if( m_generation < m_max_generation )
}
private :
const int m_generation;
const int m_max_generation;
void send_hello_to_coordinator()
{
std::ostringstream ss;
ss << "child at generation " << m_generation
<< " on thread: "
<< std::this_thread::get_id();
}
{
*this,
m_coordinator,
m_generation + 1,
m_max_generation );
} );
}
};
{
public :
a_coordinator_t( context_t ctx ) :
so_5::agent_t( ctx )
{}
{
std::cout << "hello: " << msg << std::endl;
if( 0 == (--m_remaining_messages) )
} );
}
{
create_first_child_coop();
}
private :
unsigned int m_remaining_messages = 6;
void create_first_child_coop()
{
*this,
} );
}
};
int main()
{
try
{
} );
} );
return 0;
}
catch( const std::exception & x )
{
std::cerr << "*** Exception caught: " << x.what() << std::endl;
}
return 2;
}
A helper header file for including all public SObjectizer stuff.
disp_binder_shptr_t so_this_agent_disp_binder() const
Returns the dispatcher binder that is used for binding this agent.
virtual void so_define_agent()
Hook on define agent for SObjectizer.
void so_deregister_agent_coop_normally()
A helper method for deregistering agent's coop in case of normal deregistration.
disp_binder_shptr_t so_this_coop_disp_binder() const
Returns the dispatcher binder that is used as the default binder for the agent's coop.
const mbox_t & so_direct_mbox() const
Get the agent's direct mbox.
const state_t & so_default_state() const
Access to the agent's default state.
virtual void so_evt_start()
Hook on agent start inside SObjectizer.
Agent * make_agent(Args &&... args)
Helper method for simplification of agents creation.
decltype(auto) introduce_coop(Args &&... args)
Helper method for simplification of cooperation creation and registration.
const state_t & event(Args &&... args) const
Helper for subscription of event handler in this state.
SO_5_FUNC dispatcher_handle_t make_dispatcher(environment_t &env, const std::string_view data_sources_name_base, disp_params_t params)
Create an instance of active_obj dispatcher.
Private part of message limit implementation.
void launch(Init_Routine &&init_routine)
Launch a SObjectizer Environment with default parameters.
decltype(auto) introduce_child_coop(agent_t &owner, Args &&... args)
A simple way for creating and registering child cooperation.
void send(Target &&to, Args &&... args)
A utility function for creating and delivering a message or a signal.
coop_unique_holder_t create_child_coop(agent_t &owner, Args &&... args)
A simple way for creating child cooperation.