Пример #1
0
int main()
{
	//get_unique();
	//return 0;

	wchar_t			buff[2048];
	std::wstring	type, url;
	int				correct[2] = {0,0};
	int				all[2] = {0,0};
	RSS_Feed*		feed;
	std::wifstream	f("test_list_final.txt");

	while(f.getline(buff, 2048))
	{
		f >> type >> url;
		if(type == L"RSS")
		{
			feed = RSS_create_feed(url.c_str(), error_handler_function2);
			if(feed)
				correct[0]++;
			RSS_free_feed(feed);
			all[0]++;
		}
		else if(type == L"ATOM")
		{
			feed = RSS_create_feed(url.c_str(), error_handler_function2);
			if(feed)
				correct[1]++;
			RSS_free_feed(feed);
			all[1]++;
		}
		std::wcout << L'.';
		log_result(correct,all);
	}
	std::wcout << std::endl << 
		L"RSS " << correct[0] << L"/" << all[0] << 
		L" ATOM " << correct[1] << L"/" << all[1] << std::endl;
	f.close();
	return 0;
}
Пример #2
0
int
jack_client_create_thread (jack_client_t* client,
			   pthread_t* thread,
			   int priority,
			   int realtime,
			   void*(*start_routine)(void*),
			   void* arg)
{
#ifndef JACK_USE_MACH_THREADS
	pthread_attr_t attr;
	jack_thread_arg_t* thread_args;
#endif /* !JACK_USE_MACH_THREADS */

	int result = 0;

	if (!realtime) {
		result = jack_thread_creator (thread, 0, start_routine, arg);
		if (result) {
			log_result("creating thread with default parameters",
				   result);
		}
		return result;
	}

	/* realtime thread. this disgusting mess is a reflection of
	 * the 2nd-class nature of RT programming under POSIX in
	 * general and Linux in particular.
	 */

#ifndef JACK_USE_MACH_THREADS

	pthread_attr_init(&attr);
	result = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
	if (result) {
		log_result("requesting explicit scheduling", result);
		return result;
	}
	result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
	if (result) {
		log_result("requesting joinable thread creation", result);
		return result;
	}
#ifdef __OpenBSD__
	result = pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS);
#else
	result = pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
#endif
	if (result) {
		log_result("requesting system scheduling scope", result);
		return result;
	}

        result = pthread_attr_setstacksize(&attr, THREAD_STACK); 
        if (result) {
                log_result("setting thread stack size", result);
                return result;
        }

	if ((thread_args = (jack_thread_arg_t *) malloc (sizeof (jack_thread_arg_t))) == NULL) {
		return -1;
	}

	thread_args->client = client;
	thread_args->work_function = start_routine;
	thread_args->arg = arg;
	thread_args->realtime = 1;
	thread_args->priority = priority;

	result = jack_thread_creator (thread, &attr, jack_thread_proxy, thread_args);
	if (result) {
		log_result ("creating realtime thread", result);
		return result;
	}

#else /* JACK_USE_MACH_THREADS */

	result = jack_thread_creator (thread, 0, start_routine, arg);
	if (result) {
		log_result ("creating realtime thread", result);
		return result;
	}

	/* time constraint thread */
	setThreadToPriority (*thread, 96, TRUE, 10000000);
	
#endif /* JACK_USE_MACH_THREADS */

	return 0;
}