q->running_requests++;
r->submitted = 1;
r->work.go = asio_handler;
- r->work.returned = NULL;
work_submit(&q->queue, &r->work);
}
static struct work *
work_do_wait(struct work_queue *q, int try)
{
- while (q->nr_running)
- {
- struct work *w = (try ? raw_queue_try_get : raw_queue_get)(&q->finished);
- if (!w)
- return NULL;
- q->nr_running--;
- if (w->returned)
- w->returned(q, w);
- else
- return w;
- }
- return NULL;
+ if (!q->nr_running)
+ return NULL;
+ struct work *w = (try ? raw_queue_try_get : raw_queue_get)(&q->finished);
+ if (!w)
+ return NULL;
+ q->nr_running--;
+ return w;
}
struct work *
cnode n;
struct work_queue *reply_to; // Where to queue the request when it's finished
void (*go)(struct worker_thread *t, struct work *w); // Called inside the worker thread
- void (*returned)(struct work_queue *q, struct work *w); // Called when returned back, NULL if work_wait should return
};
void worker_pool_init(struct worker_pool *p);