void
define_starter_agent(
	so_5::coop_t & coop,
	so_5::disp::prio_one_thread::strictly_ordered::private_dispatcher_t & disp )
	{
		coop.define_agent( coop.make_agent_context() + so_5::prio::p0, disp.binder() )
			.on_start( [&coop, &disp] {
				auto common_mbox = coop.environment().create_mbox();

				coop.environment().introduce_coop(
					[&]( so_5::coop_t & child )
					{
						using namespace so_5::prio;

						std::string & sequence = define_main_agent(
								child, disp, common_mbox );
						define_receiver_agent(
								child, disp, p1, common_mbox, sequence );
						define_receiver_agent(
								child, disp, p2, common_mbox, sequence );
						define_receiver_agent(
								child, disp, p3, common_mbox, sequence );
						define_receiver_agent(
								child, disp, p4, common_mbox, sequence );
						define_receiver_agent(
								child, disp, p5, common_mbox, sequence );
						define_receiver_agent(
								child, disp, p6, common_mbox, sequence );
						define_receiver_agent(
								child, disp, p7, common_mbox, sequence );
					} );

				so_5::send< msg_hello >( common_mbox );
			} );
	}
Example #2
0
void
define_message_sender(
    so_5::coop_t & coop,
    so_5::disp::prio_one_thread::quoted_round_robin::private_dispatcher_t & disp,
    const so_5::mbox_t & common_mbox )
{
    coop.define_agent( coop.make_agent_context() + so_5::prio::p0, disp.binder() )
    .event< msg_send_messages >( common_mbox, [common_mbox] {
        for( int i = 0; i != 20; ++i )
            so_5::send< msg_request >( common_mbox );
    } );
}
void
define_receiver_agent(
	so_5::coop_t & coop,
	so_5::disp::prio_one_thread::strictly_ordered::private_dispatcher_t & disp,
	so_5::priority_t priority,
	const so_5::mbox_t & common_mbox,
	std::string & sequence )
	{
		coop.define_agent( coop.make_agent_context() + priority, disp.binder() )
			.event< msg_hello >(
				common_mbox,
				[priority, &sequence] {
					sequence += std::to_string(
						static_cast< std::size_t >( priority ) );
				} );
	}
Example #4
0
void
define_receiver_agent(
    so_5::coop_t & coop,
    so_5::disp::prio_one_thread::quoted_round_robin::private_dispatcher_t & disp,
    so_5::priority_t priority,
    const so_5::mbox_t & common_mbox )
{
    coop.define_agent( coop.make_agent_context() + priority, disp.binder() )
    .on_start( [common_mbox] {
        so_5::send< msg_receiver_started >( common_mbox );
    } )
    .event< msg_request >(
        common_mbox,
    [priority, common_mbox] {
        so_5::send< msg_reply >( common_mbox, priority );
    } );
}