[med-svn] [htslib] 12/13: remove code duplication from thread_pool.c

Andreas Tille tille at debian.org
Sat Jan 30 13:23:57 UTC 2016


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository htslib.

commit 3fac82bc743e57bf34d3e8d1954e850db6cf2a8e
Author: Artem Tarasov <lomereiter at gmail.com>
Date:   Wed Sep 24 12:30:20 2014 +0400

    remove code duplication from thread_pool.c
---
 cram/thread_pool.c | 52 +---------------------------------------------------
 1 file changed, 1 insertion(+), 51 deletions(-)

diff --git a/cram/thread_pool.c b/cram/thread_pool.c
index 726d2f6..cb04f01 100644
--- a/cram/thread_pool.c
+++ b/cram/thread_pool.c
@@ -489,57 +489,7 @@ t_pool *t_pool_init(int qsize, int tsize) {
  */
 int t_pool_dispatch(t_pool *p, t_results_queue *q,
 		    void *(*func)(void *arg), void *arg) {
-    t_pool_job *j = malloc(sizeof(*j));
-
-    if (!j)
-	return -1;
-    j->func = func;
-    j->arg = arg;
-    j->next = NULL;
-    j->p = p;
-    j->q = q;
-    if (q) {
-	pthread_mutex_lock(&q->result_m);
-	j->serial = q->curr_serial++;
-	q->pending++;
-	pthread_mutex_unlock(&q->result_m);
-    } else {
-	j->serial = 0;
-    }
-
-#ifdef DEBUG
-    fprintf(stderr, "Dispatching job %p for queue %p, serial %d\n", j, q, j->serial);
-#endif
-
-    pthread_mutex_lock(&p->pool_m);
-
-    // Check if queue is full
-    while (p->njobs >= p->qsize)
-	pthread_cond_wait(&p->full_c, &p->pool_m);
-
-    p->njobs++;
-
-    if (p->tail) {
-	p->tail->next = j;
-	p->tail = j;
-    } else {
-	p->head = p->tail = j;
-    }
-
-    // Let a worker know we have data.
-#ifdef IN_ORDER
-    if (p->t_stack_top >= 0 && p->njobs > p->tsize - p->nwaiting)
-	pthread_cond_signal(&p->t[p->t_stack_top].pending_c);
-#else
-    pthread_cond_signal(&p->pending_c);
-#endif
-    pthread_mutex_unlock(&p->pool_m);
-
-#ifdef DEBUG
-    fprintf(stderr, "Dispatched (serial %d)\n", j->serial);
-#endif
-
-    return 0;
+    return t_pool_dispatch2(p, q, func, arg, 0);
 }
 
 /*

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/htslib.git



More information about the debian-med-commit mailing list