#include <iostream>
#include <string>
struct run_result
{
std::string m_result;
};
{
public :
pinger(
context_t ctx,
, m_parent(
std::move(parent) )
{}
}
[this]{
++m_pongs;
so_5::send< ping >( m_ponger );
} );
}
so_5::send< ping >( m_ponger );
}
so_5::send< run_result >(
m_parent,
"pongs: " + std::to_string( m_pongs ) );
}
private :
unsigned int m_pongs = 0;
};
{
public :
, m_parent(
std::move(parent) )
{}
}
[this]{
++m_pings;
so_5::send< pong >( m_pinger );
} );
}
so_5::send< run_result >(
m_parent,
"pings: " + std::to_string( m_pings ) );
}
private :
unsigned int m_pings = 0;
};
{
public :
{}
"pinger_ponger",
} );
st_first_result_got.
event( &parent::evt_second_result );
}
*this,
"pinger_ponger",
a_pinger->set_ponger_mbox( a_ponger->so_direct_mbox() );
a_ponger->set_pinger_mbox( a_pinger->so_direct_mbox() );
} );
so_5::send_delayed< stop >(
*this, std::chrono::seconds( 1 ) );
}
private :
const state_t st_first_result_got{
this };
std::string m_results;
void evt_first_result( const run_result & evt ) {
m_results = evt.m_result + "; ";
this >>= st_first_result_got;
}
void evt_second_result( const run_result & evt ) {
m_results += evt.m_result;
std::cout << m_results << std::endl;
}
};
int main()
{
try
{
{
} );
}
catch( const std::exception & x )
{
std::cerr << "Exception: " << x.what() << std::endl;
}
}