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 *
uns priority;
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);