nxt_buf_pool.h (65:10688b89aa16) nxt_buf_pool.h (2084:7d479274f334)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#ifndef _NXT_BUF_POOL_H_INCLUDED_
8#define _NXT_BUF_POOL_H_INCLUDED_

--- 28 unchanged lines hidden (view full) ---

37NXT_EXPORT nxt_int_t nxt_buf_pool_file_alloc(nxt_buf_pool_t *bp, size_t size);
38NXT_EXPORT nxt_int_t nxt_buf_pool_mmap_alloc(nxt_buf_pool_t *bp, size_t size);
39NXT_EXPORT void nxt_buf_pool_free(nxt_buf_pool_t *bp, nxt_buf_t *b);
40NXT_EXPORT void nxt_buf_pool_destroy(nxt_buf_pool_t *bp);
41
42
43/* There is ready free buffer. */
44
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#ifndef _NXT_BUF_POOL_H_INCLUDED_
8#define _NXT_BUF_POOL_H_INCLUDED_

--- 28 unchanged lines hidden (view full) ---

37NXT_EXPORT nxt_int_t nxt_buf_pool_file_alloc(nxt_buf_pool_t *bp, size_t size);
38NXT_EXPORT nxt_int_t nxt_buf_pool_mmap_alloc(nxt_buf_pool_t *bp, size_t size);
39NXT_EXPORT void nxt_buf_pool_free(nxt_buf_pool_t *bp, nxt_buf_t *b);
40NXT_EXPORT void nxt_buf_pool_destroy(nxt_buf_pool_t *bp);
41
42
43/* There is ready free buffer. */
44
45#define \
46nxt_buf_pool_ready(bp) \
45#define nxt_buf_pool_ready(bp) \
47 ((bp)->free != NULL \
48 || ((bp)->current != NULL \
49 && (bp)->current->mem.free < (bp)->current->mem.end))
50
51
52/* A free buffer is allowed to be allocated. */
53
46 ((bp)->free != NULL \
47 || ((bp)->current != NULL \
48 && (bp)->current->mem.free < (bp)->current->mem.end))
49
50
51/* A free buffer is allowed to be allocated. */
52
54#define \
55nxt_buf_pool_obtainable(bp) \
53#define nxt_buf_pool_obtainable(bp) \
56 ((bp)->num < (bp)->max)
57
58
59/* There is ready free buffer or it is allowed to be allocated. */
60
54 ((bp)->num < (bp)->max)
55
56
57/* There is ready free buffer or it is allowed to be allocated. */
58
61#define \
62nxt_buf_pool_available(bp) \
59#define nxt_buf_pool_available(bp) \
63 (nxt_buf_pool_obtainable(bp) || nxt_buf_pool_ready(bp))
64
65
66/* Reserve allocation of "n" free buffers as they were allocated. */
67
60 (nxt_buf_pool_obtainable(bp) || nxt_buf_pool_ready(bp))
61
62
63/* Reserve allocation of "n" free buffers as they were allocated. */
64
68#define \
69nxt_buf_pool_reserve(bp, n) \
65#define nxt_buf_pool_reserve(bp, n) \
70 (bp)->num += (n)
71
72
73/* Release a reservation. */
74
66 (bp)->num += (n)
67
68
69/* Release a reservation. */
70
75#define \
76nxt_buf_pool_release(bp, n) \
71#define nxt_buf_pool_release(bp, n) \
77 (bp)->num -= (n)
78
79
80#endif /* _NXT_BUF_POOL_H_INCLUDED_ */
72 (bp)->num -= (n)
73
74
75#endif /* _NXT_BUF_POOL_H_INCLUDED_ */