nxt_port_memory.h (197:ae8f843e1fd4) nxt_port_memory.h (206:86a529b2ea9b)
1
2/*
3 * Copyright (C) Max Romanov
4 * Copyright (C) NGINX, Inc.
5 */
6
7#ifndef _NXT_PORT_MEMORY_H_INCLUDED_
8#define _NXT_PORT_MEMORY_H_INCLUDED_
9
10
11#define PORT_MMAP_MIN_SIZE (3 * sizeof(uint32_t))
12
13typedef struct nxt_port_mmap_header_s nxt_port_mmap_header_t;
14
15void
16nxt_port_mmap_destroy(nxt_port_mmap_t *port_mmap);
17
18void nxt_port_mmaps_destroy(nxt_array_t *port_mmaps, nxt_bool_t destroy_pool);
19
20/*
21 * Allocates nxt_but_t structure from port's mem_pool, assigns this buf 'mem'
22 * pointers to first available shared mem bucket(s). 'size' used as a hint to
23 * acquire several successive buckets if possible.
24 *
25 * This function assumes that current thread operates the 'port' exclusively.
26 */
27nxt_buf_t *
28nxt_port_mmap_get_buf(nxt_task_t *task, nxt_port_t *port, size_t size);
29
30nxt_int_t nxt_port_mmap_increase_buf(nxt_task_t *task, nxt_buf_t *b,
1
2/*
3 * Copyright (C) Max Romanov
4 * Copyright (C) NGINX, Inc.
5 */
6
7#ifndef _NXT_PORT_MEMORY_H_INCLUDED_
8#define _NXT_PORT_MEMORY_H_INCLUDED_
9
10
11#define PORT_MMAP_MIN_SIZE (3 * sizeof(uint32_t))
12
13typedef struct nxt_port_mmap_header_s nxt_port_mmap_header_t;
14
15void
16nxt_port_mmap_destroy(nxt_port_mmap_t *port_mmap);
17
18void nxt_port_mmaps_destroy(nxt_array_t *port_mmaps, nxt_bool_t destroy_pool);
19
20/*
21 * Allocates nxt_but_t structure from port's mem_pool, assigns this buf 'mem'
22 * pointers to first available shared mem bucket(s). 'size' used as a hint to
23 * acquire several successive buckets if possible.
24 *
25 * This function assumes that current thread operates the 'port' exclusively.
26 */
27nxt_buf_t *
28nxt_port_mmap_get_buf(nxt_task_t *task, nxt_port_t *port, size_t size);
29
30nxt_int_t nxt_port_mmap_increase_buf(nxt_task_t *task, nxt_buf_t *b,
31 size_t size);
31 size_t size, size_t min_size);
32
33nxt_port_mmap_header_t *
34nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process,
35 nxt_fd_t fd);
36
37void
38nxt_port_mmap_write(nxt_task_t *task, nxt_port_t *port,
39 nxt_port_send_msg_t *msg, nxt_sendbuf_coalesce_t *sb);
40
41void
42nxt_port_mmap_read(nxt_task_t *task, nxt_port_t *port,
43 nxt_port_recv_msg_t *msg);
44
45enum nxt_port_method_e {
46 NXT_PORT_METHOD_ANY = 0,
47 NXT_PORT_METHOD_PLAIN,
48 NXT_PORT_METHOD_MMAP
49};
50
51typedef enum nxt_port_method_e nxt_port_method_t;
52
53nxt_port_method_t
54nxt_port_mmap_get_method(nxt_task_t *task, nxt_port_t *port, nxt_buf_t *b);
55
56
57#endif /* _NXT_PORT_MEMORY_H_INCLUDED_ */
32
33nxt_port_mmap_header_t *
34nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process,
35 nxt_fd_t fd);
36
37void
38nxt_port_mmap_write(nxt_task_t *task, nxt_port_t *port,
39 nxt_port_send_msg_t *msg, nxt_sendbuf_coalesce_t *sb);
40
41void
42nxt_port_mmap_read(nxt_task_t *task, nxt_port_t *port,
43 nxt_port_recv_msg_t *msg);
44
45enum nxt_port_method_e {
46 NXT_PORT_METHOD_ANY = 0,
47 NXT_PORT_METHOD_PLAIN,
48 NXT_PORT_METHOD_MMAP
49};
50
51typedef enum nxt_port_method_e nxt_port_method_t;
52
53nxt_port_method_t
54nxt_port_mmap_get_method(nxt_task_t *task, nxt_port_t *port, nxt_buf_t *b);
55
56
57#endif /* _NXT_PORT_MEMORY_H_INCLUDED_ */