#include <iostream>
#include <sstream>
{
public :
a_child_t(
context_t ctx,
int generation,
int max_generation )
, m_coordinator( std::move( coordinator ) )
, m_dispatcher( std::move( dispatcher ) )
, 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();
so_5::send< std::string >( m_coordinator, ss.str() );
}
{
*this,
coop.make_agent< a_child_t >(
m_coordinator,
m_dispatcher,
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,
disp.binder(),
} );
}
};
int main()
{
try
{
} );
return 0;
}
catch( const std::exception & x )
{
std::cerr << "*** Exception caught: " << x.what() << std::endl;
}
return 2;
}