#include <iostream>
struct trace_msg
{
std::string m_what;
std::thread::id m_thread_id;
};
{
public:
logger_actor( context_t ctx ) :
so_5::agent_t{ std::move(ctx) }
{
.
event( [](mhood_t<trace_msg> cmd ) {
std::cout << cmd->m_thread_id << ": (" << cmd->m_who
<< ") " << cmd->m_what << std::endl;
} );
}
};
} );
}
{
&agent, std::move(what), std::this_thread::get_id() );
}
const std::chrono::milliseconds sleeping_time{ 200 };
{
public :
A( context_t ctx ) :
so_5::agent_t{ ctx }
{
.
event( [
this]( mhood_t<M1> ) {
trace( *this, "A.e1 started" );
std::this_thread::sleep_for( sleeping_time );
trace( *this, "A.e1 finished" );
},
.event( [this]( mhood_t<M3> ) {
trace( *this, "A.e3 started" );
std::this_thread::sleep_for( sleeping_time );
trace( *this, "A.e3 finished" );
} )
}
};
{
public :
B( context_t ctx ) :
so_5::agent_t{ ctx }
{
.
event( [
this]( mhood_t<M2> ) {
trace( *this, "B.e2 started" );
std::this_thread::sleep_for( sleeping_time );
trace( *this, "B.e2 finished" );
},
}
};
{
create_logger( env );
pool_disp::bind_params_t{}.fifo( fifo_type ) ),
{
} );
so_5::send< M1 >( m );
so_5::send< M2 >( m );
so_5::send< M3 >( m );
so_5::send< M2 >( m );
so_5::send< M1 >( m );
so_5::send< stop >( m );
} );
}
int main()
{
try
{
std::cout << "cooperation FIFO..." << std::endl;
std::cout << "individual FIFO..." << std::endl;
}
catch( const std::exception & ex )
{
std::cerr << "Error: " << ex.what() << std::endl;
}
return 0;
}