typedef struct {
ngx_thread_mutex_t mtx;
- ngx_uint_t count;
ngx_thread_task_t *first;
ngx_thread_task_t **last;
} ngx_thread_pool_queue_t;
struct ngx_thread_pool_s {
- ngx_thread_cond_t cond;
-
ngx_thread_pool_queue_t queue;
+ ngx_uint_t waiting;
+ ngx_thread_cond_t cond;
ngx_log_t *log;
ngx_pool_t *pool;
static ngx_int_t
ngx_thread_pool_queue_init(ngx_thread_pool_queue_t *queue, ngx_log_t *log)
{
- queue->count = 0;
queue->first = NULL;
queue->last = &queue->first;
return NGX_ERROR;
}
- if (tp->queue.count >= tp->max_queue) {
+ if (tp->waiting >= tp->max_queue) {
(void) ngx_thread_mutex_unlock(&tp->queue.mtx, tp->log);
ngx_log_error(NGX_LOG_ERR, tp->log, 0,
"thread pool \"%V\" queue overflow: %ui tasks waiting",
- &tp->name, tp->queue.count);
+ &tp->name, tp->waiting);
return NGX_ERROR;
}
*tp->queue.last = task;
tp->queue.last = &task->next;
- tp->queue.count++;
+ tp->waiting++;
(void) ngx_thread_mutex_unlock(&tp->queue.mtx, tp->log);
return NULL;
}
- while (tp->queue.count == 0) {
+ while (tp->waiting == 0) {
if (ngx_thread_cond_wait(&tp->cond, &tp->queue.mtx, tp->log)
!= NGX_OK)
{
}
}
- tp->queue.count--;
+ tp->waiting--;
task = tp->queue.first;
tp->queue.first = task->next;