Esempio n. 1
0
int main()
{
	iv_init();

	iv_thread_set_debug_state(1);

	iv_thread_create("return", thr_return, NULL);
	iv_thread_create("selfcancel", thr_selfcancel, NULL);
	iv_thread_create("exit", thr_exit, NULL);

	iv_thread_list_children();

	iv_main();

	iv_deinit();

	return 0;
}
Esempio n. 2
0
int main()
{
	long long nsec;

	iv_init();

#ifdef USE_SIGNAL
	signal(SIGALRM, got_signal_timeout);
	alarm(5);
#else
	IV_TIMER_INIT(&timeout);
	iv_validate_now();
	timeout.expires = iv_now;
	timeout.expires.tv_sec += 5;
	timeout.handler = got_timer_timeout;
	iv_timer_register(&timeout);
#endif

	IV_EVENT_INIT(&ev_parent);
	ev_parent.handler = got_ev_parent;
	iv_event_register(&ev_parent);

	iv_thread_create("child", thr_child, NULL);

	iv_main();

	iv_deinit();

	nsec = 1000000000ULL * (tim_end.tv_sec - tim_start.tv_sec) +
		(tim_end.tv_nsec - tim_start.tv_nsec);

	printf("%s: %d in %lld nsec => %d/sec\n",
	       iv_poll_method_name(), ev_received, (long long)nsec,
	       (int)(1000000000ULL * ev_received / nsec));

	return 0;
}