void iochan_man_events(iochan_man_t man) { if (man->no_threads > 0 && !man->sel_thread) { man->sel_thread = sel_thread_create(work_handler, 0 /*work_destroy */, &man->sel_fd, man->no_threads); yaz_log(man->log_level, "iochan_man_events. Using %d threads", man->no_threads); } event_loop(man, &man->channel_list); }
/** \brief see if we can create and destroy without problems */ static void test_create_destroy(void) { int fd; sel_thread_t p = sel_thread_create(work_handler, 0, &fd, 1); YAZ_CHECK(p); if (!p) return; sel_thread_destroy(p); }
/** brief use the fd for something */ static void test_for_real_work(int no_threads) { int thread_fd; sel_thread_t p = sel_thread_create(work_handler, work_destroy, &thread_fd, no_threads); YAZ_CHECK(p); if (p) { iochan_man_t chan_man = iochan_man_create(10); IOCHAN chan = iochan_create(thread_fd, iochan_handler, EVENT_INPUT|EVENT_TIMEOUT, "test_chan"); iochan_settimeout(chan, 1); iochan_setdata(chan, p); iochan_add(chan_man, chan); iochan_man_events(chan_man); sel_thread_destroy(p); iochan_man_destroy(&chan_man); } }
static void getaddrinfo_start(iochan_man_t iochan_man) { int fd; sel_thread_t p = resolver_thread = sel_thread_create(work_handler, 0 /* work_destroy */, &fd, 3 /* no of resolver threads */); if (!p) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "sel_create_create failed"); exit(1); } else { IOCHAN chan = iochan_create(fd, iochan_handler, EVENT_INPUT, "getaddrinfo_socket"); iochan_setdata(chan, p); iochan_add(iochan_man, chan); } yaz_log(log_level, "resolver start"); resolver_thread = p; }