Lines Matching refs:tdat
43 struct tp_data *tdat = data; in tp_thread() local
49 pthread_mutex_lock(&tdat->lock); in tp_thread()
51 if (!tdat->thread_exit && flist_empty(&tdat->work)) in tp_thread()
52 pthread_cond_wait(&tdat->cv, &tdat->lock); in tp_thread()
54 if (!flist_empty(&tdat->work)) in tp_thread()
55 flist_splice_tail_init(&tdat->work, &work_list); in tp_thread()
57 pthread_mutex_unlock(&tdat->lock); in tp_thread()
60 if (tdat->thread_exit) in tp_thread()
71 void tp_queue_work(struct tp_data *tdat, struct tp_work *work) in tp_queue_work() argument
75 pthread_mutex_lock(&tdat->lock); in tp_queue_work()
76 flist_add_tail(&work->list, &tdat->work); in tp_queue_work()
77 pthread_mutex_unlock(&tdat->lock); in tp_queue_work()
79 pthread_cond_signal(&tdat->cv); in tp_queue_work()
84 struct tp_data *tdat; in tp_init() local
90 *tdatp = tdat = smalloc(sizeof(*tdat)); in tp_init()
91 pthread_mutex_init(&tdat->lock, NULL); in tp_init()
92 INIT_FLIST_HEAD(&tdat->work); in tp_init()
93 pthread_cond_init(&tdat->cv, NULL); in tp_init()
94 pthread_cond_init(&tdat->sleep_cv, NULL); in tp_init()
96 ret = pthread_create(&tdat->thread, NULL, tp_thread, tdat); in tp_init()
103 struct tp_data *tdat = *tdatp; in tp_exit() local
106 if (!tdat) in tp_exit()
109 pthread_mutex_lock(&tdat->lock); in tp_exit()
110 tdat->thread_exit = 1; in tp_exit()
111 pthread_mutex_unlock(&tdat->lock); in tp_exit()
113 pthread_cond_signal(&tdat->cv); in tp_exit()
115 pthread_join(tdat->thread, &ret); in tp_exit()
117 sfree(tdat); in tp_exit()