Example #1
0
int main()
{
    boost::thread con1(&consumer, 1);
    boost::thread con2(&consumer, 2);

    boost::thread prod(&producer);

    prod.join();
    con1.join();
    con2.join();
}
BOOST_FIXTURE_TEST_CASE( write_queue_used_by_other_client, large_fixture )
{
    connection_data con1( 23 );
    connection_data con2( 23 );

    l2cap_input( { 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 }, con1 );
    expected_result( { 0x17, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 } );

    l2cap_input( { 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 }, con2 );
    expected_result( { 0x01, 0x16, 0x03, 0x00, 0x09 } );
}
BOOST_FIXTURE_TEST_CASE( queue_can_be_used_after_beeing_released, test::request_with_reponse< three_apes_server > )
{
    connection_data con1( 23 );
    connection_data con2( 23 );

    l2cap_input( { 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 }, con1 );

    l2cap_input( { 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 }, con2 );
    expected_result( { 0x01, 0x16, 0x03, 0x00, 0x09 } );

    this->client_disconnected( con1 );

    l2cap_input( { 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 }, con2 );
    expected_result( { 0x17, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 } );
}
Example #4
0
TEST (message, confirm_ack_serialization)
{
	rai::keypair key1;
	auto vote (std::make_shared<rai::vote> (key1.pub, key1.prv, 0, std::unique_ptr<rai::block> (new rai::send_block (0, 1, 2, key1.prv, 4, 5))));
	rai::confirm_ack con1 (vote);
	std::vector<uint8_t> bytes;
	{
		rai::vectorstream stream1 (bytes);
		con1.serialize (stream1);
	}
	rai::bufferstream stream2 (bytes.data (), bytes.size ());
	bool error;
	rai::message_header header (error, stream2);
	rai::confirm_ack con2 (error, stream2, header);
	ASSERT_FALSE (error);
	ASSERT_EQ (con1, con2);
}
Example #5
0
void
fruitapp::gui::ce::post_model::post(
	fruitapp::highscore::name const &_name,
	fruitapp::highscore::score const &_score)
{
	for(
		fruitapp::gui::ce::table::row_index::value_type i =
			static_cast<fruitapp::gui::ce::table::row_index::value_type>(connections_.size()-1);
		i != static_cast<fruitapp::gui::ce::table::row_index::value_type>(-1);
		--i)
		row_removed_(
			i);

	for(
		highscore::provider_sequence::iterator i =
			providers_.begin();
		i != providers_.end();
		++i)
	{
		fruitapp::highscore::provider::connection_base_ptr new_connection(
			(*i)->create_connection());

		fruitapp::gui::ce::table::row new_row;
		new_row.push_back(
			(*i)->identifier());
		new_row.push_back(
			FCPPT_TEXT(""));

		fruitapp::gui::ce::table::row_index::value_type const new_row_index =
			static_cast<fruitapp::gui::ce::table::row_index::value_type>(
				std::distance(
					providers_.begin(),
					i));

		row_added_(
			new_row_index,
			new_row);

		fcppt::signal::auto_connection con1(
			new_connection->message_received(
				fruitapp::highscore::callbacks::message_received{
					std::bind(
						&post_model::message_received_internal,
						this,
						std::cref(
							**i),
						std::placeholders::_1
					)
				}
			)
		);

		fcppt::signal::auto_connection con2(
			new_connection->error_received(
				fruitapp::highscore::callbacks::error_received{
					std::bind(
						&post_model::error_received_internal,
						this,
						std::cref(
							**i),
						std::placeholders::_1
					)
				}
			)
		);

		fcppt::signal::auto_connection con3(
			new_connection->rank_received(
				fruitapp::highscore::callbacks::rank_received{
					std::bind(
						&post_model::rank_received_internal,
						this,
						std::cref(
							**i),
						new_row_index,
						std::placeholders::_1
					)
				}
			)
		);

		connections_.push_back(
			fcppt::make_unique_ptr<connection_wrapper>(
				std::move(
					new_connection),
				std::move(
					con1),
				std::move(
					con2),
				std::move(
					con3)));

		connections_.back()->connection().post_rank(
			_name,
			_score);
	}
}