Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}