Mercurial > hg > nginx
diff 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 |
line wrap: on
line diff
--- a/src/core/ngx_slab.h +++ b/src/core/ngx_slab.h @@ -12,32 +12,34 @@ #include <ngx_core.h> -typedef struct ngx_free_slab_s ngx_free_slab_t; - -typedef struct ngx_free_slab_s { - ngx_free_slab_t *next; -} - +typedef struct ngx_slab_page_s ngx_slab_page_t; -typedef struct ngx_slab_block_s ngx_slab_block_t; - -typedef struct ngx_slab_block_s { - ngx_free_slab_t *free; - ngx_slab_buf_t *next; - size_t color; +struct ngx_slab_page_s { + uintptr_t slab; + ngx_slab_page_t *next; + uintptr_t prev; }; typedef struct { - ngx_slab_buf_t *blocks; - size_t size; + ngx_atomic_t lock; + + size_t min_size; + size_t min_shift; - void *start; - uint32_t map; + ngx_slab_page_t *pages; + ngx_slab_page_t free; - ngx_log_t *log; - ngx_free_pool_t free; + u_char *start; + u_char *end; + + ngx_shmtx_t mutex; } ngx_slab_pool_t; +void ngx_slab_init(ngx_slab_pool_t *pool); +void *ngx_slab_alloc(ngx_slab_pool_t *pool, size_t size); +void ngx_slab_free(ngx_slab_pool_t *pool, void *p); + + #endif /* _NGX_SLAB_H_INCLUDED_ */