Commit 067662b5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Prepare for having more than two task queues, by turning them into

an array of queues.
parent a84f28ee
......@@ -315,7 +315,8 @@ struct pool_task {
enum task_how {
TASK_QUEUE_FRONT,
TASK_QUEUE_BACK
TASK_QUEUE_BACK,
TASK_QUEUE_END
};
/*--------------------------------------------------------------------*/
......
......@@ -149,6 +149,7 @@ static struct pool *
pool_mkpool(unsigned pool_no)
{
struct pool *pp;
int i;
ALLOC_OBJ(pp, POOL_MAGIC);
if (pp == NULL)
......@@ -160,8 +161,8 @@ pool_mkpool(unsigned pool_no)
Lck_New(&pp->mtx, lck_wq);
VTAILQ_INIT(&pp->idle_queue);
VTAILQ_INIT(&pp->front_queue);
VTAILQ_INIT(&pp->back_queue);
for (i = 0; i < TASK_QUEUE_END; i++)
VTAILQ_INIT(&pp->queues[i]);
AZ(pthread_cond_init(&pp->herder_cond, NULL));
AZ(pthread_create(&pp->herder_thr, NULL, pool_herder, pp));
......
......@@ -43,8 +43,7 @@ struct pool {
struct lock mtx;
struct taskhead idle_queue;
struct taskhead front_queue;
struct taskhead back_queue;
struct taskhead queues[TASK_QUEUE_END];
unsigned nthr;
unsigned dry;
unsigned lqueue;
......
......@@ -251,13 +251,14 @@ Pool_Task(struct pool *pp, struct pool_task *task, enum task_how how)
pp->ndropped++;
retval = -1;
} else {
VTAILQ_INSERT_TAIL(&pp->front_queue, task, list);
VTAILQ_INSERT_TAIL(&pp->queues[how], task, list);
pp->nqueued++;
pp->lqueue++;
}
break;
case TASK_QUEUE_BACK:
VTAILQ_INSERT_TAIL(&pp->back_queue, task, list);
VTAILQ_INSERT_TAIL(&pp->queues[how], task, list);
pp->lqueue++;
break;
default:
WRONG("Unknown enum task_how");
......@@ -299,14 +300,13 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk)
WS_Reset(wrk->aws, NULL);
AZ(wrk->vsl);
tp = VTAILQ_FIRST(&pp->front_queue);
if (tp != NULL) {
pp->lqueue--;
VTAILQ_REMOVE(&pp->front_queue, tp, list);
} else {
tp = VTAILQ_FIRST(&pp->back_queue);
if (tp != NULL)
VTAILQ_REMOVE(&pp->back_queue, tp, list);
for (i = 0; i < TASK_QUEUE_END; i++) {
tp = VTAILQ_FIRST(&pp->queues[i]);
if (tp != NULL) {
pp->lqueue--;
VTAILQ_REMOVE(&pp->queues[i], tp, list);
break;
}
}
if ((tp == NULL && wrk->stats->summs > 0) ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment