Skip to content

Commit

Permalink
ngx_thread_pool.h
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrono Law committed Apr 1, 2016
1 parent 706539c commit 32706c0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nginx/src/core/ngx_thread_pool.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// annotated by chrono since 2016

/*
* Copyright (C) Nginx, Inc.
Expand All @@ -13,7 +14,10 @@
#include <ngx_core.h>
#include <ngx_event.h>

// 编译时需使用选项--with-threads
// thread_pool指令需要在main域配置

// 线程执行的任务结构体,handler是真正被线程执行的函数
struct ngx_thread_task_s {
ngx_thread_task_t *next;
ngx_uint_t id;
Expand All @@ -27,9 +31,14 @@ typedef struct ngx_thread_pool_s ngx_thread_pool_t;


ngx_thread_pool_t *ngx_thread_pool_add(ngx_conf_t *cf, ngx_str_t *name);

// 根据名字获取线程池
ngx_thread_pool_t *ngx_thread_pool_get(ngx_cycle_t *cycle, ngx_str_t *name);

// 创建一个线程任务结构体
ngx_thread_task_t *ngx_thread_task_alloc(ngx_pool_t *pool, size_t size);

// 把任务放入线程池,由线程执行
ngx_int_t ngx_thread_task_post(ngx_thread_pool_t *tp, ngx_thread_task_t *task);


Expand Down

0 comments on commit 32706c0

Please sign in to comment.