| 1 |
#ifndef AWS_IO_MESSAGE_POOL_H |
| 2 |
#define AWS_IO_MESSAGE_POOL_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#include <aws/common/array_list.h> |
| 8 |
#include <aws/io/io.h> |
| 9 |
|
| 10 |
AWS_PUSH_SANE_WARNING_LEVEL |
| 11 |
|
| 12 |
struct aws_memory_pool { |
| 13 |
struct aws_allocator *alloc; |
| 14 |
struct aws_array_list stack; |
| 15 |
uint16_t ideal_segment_count; |
| 16 |
size_t segment_size; |
| 17 |
void *data_ptr; |
| 18 |
}; |
| 19 |
|
| 20 |
struct aws_message_pool { |
| 21 |
struct aws_allocator *alloc; |
| 22 |
struct aws_memory_pool application_data_pool; |
| 23 |
struct aws_memory_pool small_block_pool; |
| 24 |
}; |
| 25 |
|
| 26 |
struct aws_message_pool_creation_args { |
| 27 |
size_t application_data_msg_data_size; |
| 28 |
uint8_t application_data_msg_count; |
| 29 |
size_t small_block_msg_data_size; |
| 30 |
uint8_t small_block_msg_count; |
| 31 |
}; |
| 32 |
|
| 33 |
AWS_EXTERN_C_BEGIN |
| 34 |
|
| 35 |
AWS_IO_API |
| 36 |
int aws_memory_pool_init( |
| 37 |
struct aws_memory_pool *mempool, |
| 38 |
struct aws_allocator *alloc, |
| 39 |
uint16_t ideal_segment_count, |
| 40 |
size_t segment_size); |
| 41 |
|
| 42 |
AWS_IO_API |
| 43 |
void aws_memory_pool_clean_up(struct aws_memory_pool *mempool); |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
AWS_IO_API |
| 49 |
void *aws_memory_pool_acquire(struct aws_memory_pool *mempool); |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
AWS_IO_API |
| 55 |
void aws_memory_pool_release(struct aws_memory_pool *mempool, void *to_release); |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
AWS_IO_API |
| 61 |
int aws_message_pool_init( |
| 62 |
struct aws_message_pool *msg_pool, |
| 63 |
struct aws_allocator *alloc, |
| 64 |
struct aws_message_pool_creation_args *args); |
| 65 |
|
| 66 |
AWS_IO_API |
| 67 |
void aws_message_pool_clean_up(struct aws_message_pool *msg_pool); |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
AWS_IO_API |
| 74 |
struct aws_io_message *aws_message_pool_acquire( |
| 75 |
struct aws_message_pool *msg_pool, |
| 76 |
enum aws_io_message_type message_type, |
| 77 |
size_t size_hint); |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
AWS_IO_API |
| 84 |
void aws_message_pool_release(struct aws_message_pool *msg_pool, struct aws_io_message *message); |
| 85 |
|
| 86 |
AWS_EXTERN_C_END |
| 87 |
AWS_POP_SANE_WARNING_LEVEL |
| 88 |
|
| 89 |
#endif |