Lines Matching refs:tp

38 static void l9p_threadpool_rflush(struct l9p_threadpool *tp,
44 struct l9p_threadpool *tp; in l9p_responder() local
48 tp = worker->ltw_tp; in l9p_responder()
51 pthread_mutex_lock(&tp->ltp_mtx); in l9p_responder()
52 while (STAILQ_EMPTY(&tp->ltp_replyq) && !worker->ltw_exiting) in l9p_responder()
53 pthread_cond_wait(&tp->ltp_reply_cv, &tp->ltp_mtx); in l9p_responder()
55 pthread_mutex_unlock(&tp->ltp_mtx); in l9p_responder()
60 req = STAILQ_FIRST(&tp->ltp_replyq); in l9p_responder()
61 STAILQ_REMOVE_HEAD(&tp->ltp_replyq, lr_worklink); in l9p_responder()
68 l9p_threadpool_rflush(tp, req); in l9p_responder()
70 pthread_mutex_unlock(&tp->ltp_mtx); in l9p_responder()
81 struct l9p_threadpool *tp; in l9p_worker() local
85 tp = worker->ltw_tp; in l9p_worker()
86 pthread_mutex_lock(&tp->ltp_mtx); in l9p_worker()
88 while (STAILQ_EMPTY(&tp->ltp_workq) && !worker->ltw_exiting) in l9p_worker()
89 pthread_cond_wait(&tp->ltp_work_cv, &tp->ltp_mtx); in l9p_worker()
94 req = STAILQ_FIRST(&tp->ltp_workq); in l9p_worker()
95 STAILQ_REMOVE_HEAD(&tp->ltp_workq, lr_worklink); in l9p_worker()
98 pthread_mutex_unlock(&tp->ltp_mtx); in l9p_worker()
104 pthread_mutex_lock(&tp->ltp_mtx); in l9p_worker()
107 STAILQ_INSERT_TAIL(&tp->ltp_replyq, req, lr_worklink); in l9p_worker()
110 pthread_cond_signal(&tp->ltp_reply_cv); in l9p_worker()
112 pthread_mutex_unlock(&tp->ltp_mtx); in l9p_worker()
123 l9p_threadpool_rflush(struct l9p_threadpool *tp, struct l9p_request *req) in l9p_threadpool_rflush() argument
151 STAILQ_INSERT_TAIL(&tp->ltp_replyq, flusher, lr_worklink); in l9p_threadpool_rflush()
156 l9p_threadpool_init(struct l9p_threadpool *tp, int size) in l9p_threadpool_init() argument
167 error = pthread_mutex_init(&tp->ltp_mtx, NULL); in l9p_threadpool_init()
170 error = pthread_cond_init(&tp->ltp_work_cv, NULL); in l9p_threadpool_init()
173 error = pthread_cond_init(&tp->ltp_reply_cv, NULL); in l9p_threadpool_init()
177 STAILQ_INIT(&tp->ltp_workq); in l9p_threadpool_init()
178 STAILQ_INIT(&tp->ltp_replyq); in l9p_threadpool_init()
179 LIST_INIT(&tp->ltp_workers); in l9p_threadpool_init()
185 worker->ltw_tp = tp; in l9p_threadpool_init()
208 LIST_INSERT_HEAD(&tp->ltp_workers, worker, ltw_link); in l9p_threadpool_init()
212 l9p_threadpool_shutdown(tp); in l9p_threadpool_init()
224 pthread_cond_destroy(&tp->ltp_work_cv); in l9p_threadpool_init()
226 pthread_mutex_destroy(&tp->ltp_mtx); in l9p_threadpool_init()
235 l9p_threadpool_run(struct l9p_threadpool *tp, struct l9p_request *req) in l9p_threadpool_run() argument
248 pthread_mutex_lock(&tp->ltp_mtx); in l9p_threadpool_run()
250 STAILQ_INSERT_TAIL(&tp->ltp_workq, req, lr_worklink); in l9p_threadpool_run()
251 pthread_cond_signal(&tp->ltp_work_cv); in l9p_threadpool_run()
252 pthread_mutex_unlock(&tp->ltp_mtx); in l9p_threadpool_run()
264 struct l9p_threadpool *tp; in l9p_threadpool_tflush() local
274 tp = &conn->lc_tp; in l9p_threadpool_tflush()
285 pthread_mutex_lock(&tp->ltp_mtx); in l9p_threadpool_tflush()
293 pthread_mutex_lock(&tp->ltp_mtx); in l9p_threadpool_tflush()
384 pthread_mutex_unlock(&tp->ltp_mtx); in l9p_threadpool_tflush()
394 STAILQ_INSERT_TAIL(&tp->ltp_replyq, req, lr_worklink); in l9p_threadpool_tflush()
395 pthread_mutex_unlock(&tp->ltp_mtx); in l9p_threadpool_tflush()
396 pthread_cond_signal(&tp->ltp_reply_cv); in l9p_threadpool_tflush()
401 l9p_threadpool_shutdown(struct l9p_threadpool *tp) in l9p_threadpool_shutdown() argument
405 LIST_FOREACH_SAFE(worker, &tp->ltp_workers, ltw_link, tmp) { in l9p_threadpool_shutdown()
406 pthread_mutex_lock(&tp->ltp_mtx); in l9p_threadpool_shutdown()
409 pthread_cond_signal(&tp->ltp_reply_cv); in l9p_threadpool_shutdown()
411 pthread_cond_broadcast(&tp->ltp_work_cv); in l9p_threadpool_shutdown()
412 pthread_mutex_unlock(&tp->ltp_mtx); in l9p_threadpool_shutdown()
417 pthread_cond_destroy(&tp->ltp_reply_cv); in l9p_threadpool_shutdown()
418 pthread_cond_destroy(&tp->ltp_work_cv); in l9p_threadpool_shutdown()
419 pthread_mutex_destroy(&tp->ltp_mtx); in l9p_threadpool_shutdown()