Example #1
0
bool test_helper(trassel::GroupMode::GroupMode_t mode) {
	ConcreteDirectedChannel channel;
	Group group(&channel, mode);
	GroupRunner groupRunner(&group);
	TestGroupConsumer gc1(&group);
	TestGroupConsumer gc2(&group);
	TestGroupConsumer tc1(&channel);
	TestGroupProducer tpc(&channel, &tc1);
	TestGroupProducer tpg(&channel, &group);
	id_collection coll(gc1.getID(), gc2.getID(), tc1.getID(), tpg.getID(), tpc.getID());
	cout <<"gc1(" <<(int)gc1.getID() <<") gc2(" <<(int)gc2.getID() <<")" <<endl;
	cout <<"tc1(" <<(int)tc1.getID() <<")" <<endl;
	cout <<"tpg(" <<(int)tpg.getID() <<") tpc(" <<(int)tpc.getID() <<")" <<endl;
	new boost::thread(groupRunner);
	new boost::thread(gc1);
	new boost::thread(gc2);
	new boost::thread(tpg);
	new boost::thread(tc1);
	new boost::thread(tpc);
	Timer::sleep(100);
	channel.close();
	lock mlock(groupOutputMutex);
	for(uint32 a = 0; a < groupOutput.size(); ++a)
		cout <<groupOutput[a] <<", ";
	cout <<endl;
	Timer::sleep(100); //wait for console output
	bool success = false;
	if(group.getMode() == GroupMode::Broadcast)
		return validate_producers_broadcast(groupOutput, coll);
	else
		return validate_producers_first(groupOutput, coll);

}
Example #2
0
bool test_helper(trassel::GroupMode::GroupMode_t mode) {
	ConcreteDirectedChannel channel;
	Group group(&channel, mode);
	Runner<Group> groupRunner(&group);
	TestGroupConsumer gc1(&group);
    Runner<TestGroupConsumer> gc1_runner(&gc1);
	TestGroupConsumer gc2(&group);
    Runner<TestGroupConsumer> gc2_runner(&gc1);
	TestGroupConsumer tc1(&channel);
	TestGroupProducer tpc(&channel, &tc1);
	TestGroupProducer tpg(&channel, &group);
	idToName.clear();
	idToName[gc1.getID()] = "gc1";
	idToName[gc2.getID()] = "gc2";
	idToName[tc1.getID()] = "tc1";
	idToName[tpc.getID()] = "tpc";
	idToName[tpg.getID()] = "tpg";
    coll = new id_collection(gc1.getID(), gc2.getID(), tc1.getID(), tpg.getID(), tpc.getID());
	cout <<"gc1(" <<(int)gc1.getID() <<") gc2(" <<(int)gc2.getID() <<")" <<endl;
	cout <<"tc1(" <<(int)tc1.getID() <<")" <<endl;
	cout <<"tpg(" <<(int)tpg.getID() <<") tpc(" <<(int)tpc.getID() <<")" <<endl;
	new boost::thread(groupRunner);
	new boost::thread(gc1_runner);
	new boost::thread(gc2_runner);
	new boost::thread(tpg);
	new boost::thread(tc1);
	new boost::thread(tpc);
	Timer::sleep(10000); //handle all signals
	group.quit();
	channel.close();
	lock mlock(groupOutputMutex);
	for(uint32 a = 0; a < groupOutput.size(); ++a)
		cout <<idToName[groupOutput[a]] <<", ";
	cout <<endl;
	Timer::sleep(100); //wait for console output
	bool success = false;
	if(group.getMode() == GroupMode::Broadcast)
		success = validate_producers_broadcast(groupOutput, *coll);
	else
		success = validate_producers_first(groupOutput, *coll);
	mlock.unlock();
    delete coll;
	return success;
}