/* Add new write thread. */ struct thread * thread_add_write (struct lib_globals *zg, int (*func) (struct thread *), void *arg, int fd) { struct thread_master *m = zg->master; struct thread *thread; pal_assert (m != NULL); if (fd < 0 || PAL_SOCK_HANDLESET_ISSET (fd, &m->writefd)) return NULL; thread = thread_get (zg, THREAD_WRITE, func, arg); if (thread == NULL) return NULL; thread_update_max_fd (m, fd); PAL_SOCK_HANDLESET_SET (fd, &m->writefd); thread->u.fd = fd; thread_list_add (&m->write, thread); return thread; }
/* Add new high priority read thread. */ struct thread * thread_add_read_high (struct thread_master *master, int (*func) (struct thread *), void *arg, int fd) { struct thread_master *m = master; struct thread *thread; assert (m != NULL); if (fd < 0) return NULL; thread = thread_get (master, THREAD_READ_HIGH, func, arg); if (thread == NULL) return NULL; thread_update_max_fd (m, fd); PAL_SOCK_HANDLESET_SET (fd, &m->readfd); thread->u.fd = fd; thread_list_add (&m->read_high, thread); return thread; }