Mercurial > hg > nginx
comparison src/core/ngx_slab.h @ 860:201d017ea470
slab allocator in shared memory
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 20 Nov 2006 08:51:45 +0000 |
parents | 42d11f017717 |
children | 715336c243e1 |
comparison
equal
deleted
inserted
replaced
859:d1e8c59a50ee | 860:201d017ea470 |
---|---|
10 | 10 |
11 #include <ngx_config.h> | 11 #include <ngx_config.h> |
12 #include <ngx_core.h> | 12 #include <ngx_core.h> |
13 | 13 |
14 | 14 |
15 typedef struct ngx_free_slab_s ngx_free_slab_t; | 15 typedef struct ngx_slab_page_s ngx_slab_page_t; |
16 | 16 |
17 typedef struct ngx_free_slab_s { | 17 struct ngx_slab_page_s { |
18 ngx_free_slab_t *next; | 18 uintptr_t slab; |
19 } | 19 ngx_slab_page_t *next; |
20 | 20 uintptr_t prev; |
21 | |
22 typedef struct ngx_slab_block_s ngx_slab_block_t; | |
23 | |
24 typedef struct ngx_slab_block_s { | |
25 ngx_free_slab_t *free; | |
26 ngx_slab_buf_t *next; | |
27 size_t color; | |
28 }; | 21 }; |
29 | 22 |
30 | 23 |
31 typedef struct { | 24 typedef struct { |
32 ngx_slab_buf_t *blocks; | 25 ngx_atomic_t lock; |
33 size_t size; | |
34 | 26 |
35 void *start; | 27 size_t min_size; |
36 uint32_t map; | 28 size_t min_shift; |
37 | 29 |
38 ngx_log_t *log; | 30 ngx_slab_page_t *pages; |
39 ngx_free_pool_t free; | 31 ngx_slab_page_t free; |
32 | |
33 u_char *start; | |
34 u_char *end; | |
35 | |
36 ngx_shmtx_t mutex; | |
40 } ngx_slab_pool_t; | 37 } ngx_slab_pool_t; |
41 | 38 |
42 | 39 |
40 void ngx_slab_init(ngx_slab_pool_t *pool); | |
41 void *ngx_slab_alloc(ngx_slab_pool_t *pool, size_t size); | |
42 void ngx_slab_free(ngx_slab_pool_t *pool, void *p); | |
43 | |
44 | |
43 #endif /* _NGX_SLAB_H_INCLUDED_ */ | 45 #endif /* _NGX_SLAB_H_INCLUDED_ */ |