当前位置: 首页>>代码示例>>C++>>正文


C++ so_5::environment_t类代码示例

本文整理汇总了C++中so_5::environment_t的典型用法代码示例。如果您正苦于以下问题:C++ environment_t类的具体用法?C++ environment_t怎么用?C++ environment_t使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了environment_t类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: create_and_register_agent

void
create_and_register_agent(
	so_5::environment_t & env,
	const std::string & parent_coop_name,
	int ordinal,
	int max_children,
	int level,
	int max_deep )
{
	so_5::coop_unique_ptr_t coop = env.create_coop(
			create_coop_name( parent_coop_name, level, ordinal ) );
	if( level )
		coop->set_parent_coop_name( parent_coop_name );

	coop->add_agent(
			new a_test_t(
					env,
					coop->query_coop_name(),
					parent_coop_name,
					max_children,
					level,
					max_deep ) );

	env.register_coop( std::move( coop ) );
}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:25,代码来源:main.cpp

示例2: reg_coop

void
reg_coop(
	so_5::environment_t & env )
{
	so_5::coop_unique_ptr_t coop =
		env.create_coop( "test_coop" );

	coop->add_agent( new a_ordinary_t( env ) );
	coop->add_agent( new a_ordinary_t( env ) );
	coop->add_agent( new a_ordinary_t( env ) );
	coop->add_agent( new a_ordinary_t( env ) );
	coop->add_agent( new a_ordinary_t( env ) );

	// This agent will throw an exception during binding for dispatcher.
	coop->add_agent(
		new a_throwing_t( env ),
		so_5::disp_binder_unique_ptr_t( new throwing_disp_binder_t ) );

	coop->add_agent( new a_ordinary_t( env ) );
	coop->add_agent( new a_ordinary_t( env ) );
	coop->add_agent( new a_ordinary_t( env ) );
	coop->add_agent( new a_ordinary_t( env ) );

	try
	{
		env.register_coop( std::move( coop ) );
	}
	catch(...) {}
}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:29,代码来源:main.cpp

示例3: init

// The SObjectizer Environment initialization.
void init( so_5::environment_t & env )
{
	// Creating and registering a cooperation.
	env.register_agent_as_coop( "coop", env.make_agent< a_hello_t >() );

	// Stopping SObjectizer.
	env.stop();
}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:9,代码来源:main.cpp

示例4: init

void
init( so_5::environment_t & env )
{
	auto coop = env.create_coop( "test" );
	coop->add_agent( new a_parent_t( env ) );
	coop->add_agent( new a_time_sentinel_t( env ) );

	env.register_coop( std::move( coop ) );
}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:9,代码来源:main.cpp

示例5: init

void
init( so_5::environment_t & env )
{
	auto coop = env.create_coop( "driver",
			so_5::disp::active_obj::create_disp_binder( "active_obj" ) );

	coop->add_agent( new a_driver_t( env ) );
	coop->add_agent( new a_time_sentinel_t( env ) );

	env.register_coop( std::move( coop ) );
}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:11,代码来源:main.cpp

示例6: init

void
init( so_5::environment_t & env )
{
	env.introduce_coop(
			so_5::disp::active_obj::create_private_disp( env )->binder(),
			[&]( so_5::coop_t & coop ) {
				const auto mbox = env.create_mbox();

				coop.make_agent< a_provider_t >( mbox );
				coop.make_agent< a_consumer_t >( mbox );
			} );
}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:12,代码来源:main.cpp

示例7: init

void
init( so_5::environment_t & env )
{
	env.introduce_coop( []( so_5::coop_t & coop ) {
			coop.make_agent< a_test_t >( coop.environment().create_mbox() );
		} );
}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:7,代码来源:main.cpp

示例8: do_check_wait_remove_oldest_impl

void
do_check_wait_remove_oldest_impl(
	so_5::environment_t & env,
	const char * case_name,
	props::memory_usage_t memory )
{
	cout << "wait, remove_oldest, " << case_name << ": " << std::flush;

	auto ch = env.create_mchain(
			so_5::make_limited_with_waiting_mchain_params(
					3,
					memory,
					props::overflow_reaction_t::remove_oldest,
					wait_timeout ) );

	so_5::send< int >( ch, 1 );
	so_5::send< int >( ch, 2 );
	so_5::send< int >( ch, 3 );
	check_pause( [&] { so_5::send< int >( ch, 4 ); } );

	receive( from(ch).handle_n(4).empty_timeout(so_5::no_wait),
			[]( int i ) { UT_CHECK_CONDITION( i > 1 ); } );

	cout << "OK" << std::endl;
}
开发者ID:gitter-badger,项目名称:SObjectizer,代码行数:25,代码来源:main.cpp

示例9: do_check_no_wait_throw_exception_impl

void
do_check_no_wait_throw_exception_impl(
	so_5::environment_t & env,
	const char * case_name,
	props::memory_usage_t memory )
{
	cout << "no_wait, throw_exception, " << case_name << ": " << std::flush;

	auto ch = env.create_mchain(
			so_5::make_limited_without_waiting_mchain_params(
					3,
					memory,
					props::overflow_reaction_t::throw_exception ) );

	so_5::send< int >( ch, 1 );
	so_5::send< int >( ch, 2 );
	so_5::send< int >( ch, 3 );
	try
	{
		so_5::send< int >( ch, 4 );
		UT_CHECK_CONDITION( !"An exception must be throw before this line!" );
	}
	catch( const so_5::exception_t & ex )
	{
		UT_CHECK_CONDITION( so_5::rc_msg_chain_overflow == ex.error_code() );
	}

	cout << "OK" << std::endl;
}
开发者ID:gitter-badger,项目名称:SObjectizer,代码行数:29,代码来源:main.cpp

示例10: init

void
init(
	so_5::environment_t & env )
	{
		auto coop = env.create_coop(
				"test_coop",
				so_5::disp::active_obj::create_disp_binder( "active_obj" ) );

		auto svc_mbox = env.create_mbox();

		coop->add_agent( new a_convert_service_t( env, svc_mbox ) );
		coop->add_agent( new a_convert_service_t( env, svc_mbox ) );
		coop->add_agent( new a_client_t( env, svc_mbox ) );
		coop->add_agent( new a_time_sentinel_t( env ) );

		env.register_coop( std::move( coop ) );
	}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:17,代码来源:main.cpp

示例11: init

void
init( so_5::environment_t & env )
{
	env.introduce_coop( []( so_5::coop_t & coop ) {
		coop.set_exception_reaction( so_5::shutdown_sobjectizer_on_exception );
		coop.make_agent< a_test_t >();
	} );
}
开发者ID:gitter-badger,项目名称:SObjectizer,代码行数:8,代码来源:main.cpp

示例12: a_test_t

		a_test_t(
			so_5::environment_t & env,
			int & message_counter )
			:	base_type_t( env )
			,	m_message_counter( message_counter )
			,	m_mbox( env.create_mbox() )
		{
		}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:8,代码来源:main.cpp

示例13: a_test_t

		a_test_t(
			so_5::environment_t & env,
			const so_5::coop_reg_notificator_t & reg_notificator,
			const so_5::coop_dereg_notificator_t & dereg_notificator )
			:	base_type_t( env )
			,	m_reg_notificator( reg_notificator )
			,	m_dereg_notificator( dereg_notificator )
			,	m_mbox( env.create_mbox() )
		{}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:9,代码来源:main.cpp

示例14: send_delayed

			static void
			send_delayed(
				so_5::environment_t & env,
				const so_5::mbox_t & to,
				std::chrono::steady_clock::duration pause,
				ARGS &&... args )
				{
					env.single_timer(
							so_5::details::make_message_instance< MESSAGE >(
								std::forward< ARGS >( args )...),
							to, pause );
				}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:12,代码来源:send_functions.hpp

示例15: send_periodic

			static timer_id_t
			send_periodic(
				so_5::environment_t & env,
				const so_5::mbox_t & to,
				std::chrono::steady_clock::duration pause,
				std::chrono::steady_clock::duration period,
				ARGS &&... args )
				{
					return env.schedule_timer( 
							so_5::details::make_message_instance< MESSAGE >(
								std::forward< ARGS >( args )...),
							to, pause, period );
				}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:13,代码来源:send_functions.hpp


注:本文中的so_5::environment_t类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。