Example #1
0
bool CmdTestThreads::v_processArguments( int argc, char** argv, af::Msg &msg)
{
	int count = atoi(argv[0]);

	for( int i = 0; i < count; i++)
	{
		af::sleep_msec(1);

		DlThread *t = new DlThread();
		int * args = new int[1024];
		args[0] = i;

		t->SetDetached();
		int result = t->Start( testThread, args);

		switch( result)
		{
			case 0:
				continue;

			case EAGAIN:
				printf("Insufficient resources to create another thread [%d].\n", i);
				break;

			case EINVAL:
				printf("Invalid thread settings [%d].\n", i);
				break;

			case EPERM:
				printf("No permission to set the scheduling policy and parameters specified [%d].\n", i);
				break;

			default:
				AF_ERR << "Unknown error [" << i << "].";
		}

		return true;
	}

	af::sleep_sec(2);

	return true;
}