00001
00002
00003
00009 #ifndef _TOR_MEMPOOL_H
00010 #define _TOR_MEMPOOL_H
00011
00015 typedef struct mp_pool_t mp_pool_t;
00016
00017 void *mp_pool_get(mp_pool_t *pool);
00018 void mp_pool_release(void *item);
00019 mp_pool_t *mp_pool_new(size_t item_size, size_t chunk_capacity);
00020 void mp_pool_clean(mp_pool_t *pool, int n_to_keep, int keep_recently_used);
00021 void mp_pool_destroy(mp_pool_t *pool);
00022 void mp_pool_assert_ok(mp_pool_t *pool);
00023 void mp_pool_log_status(mp_pool_t *pool, int severity);
00024
00025 #define MEMPOOL_STATS
00026
00027 #ifdef MEMPOOL_PRIVATE
00028
00029
00030 struct mp_pool_t {
00033 struct mp_chunk_t *empty_chunks;
00037 struct mp_chunk_t *used_chunks;
00040 struct mp_chunk_t *full_chunks;
00042 int n_empty_chunks;
00045 int min_empty_chunks;
00047 int new_chunk_capacity;
00050 size_t item_alloc_size;
00051 #ifdef MEMPOOL_STATS
00052
00053 uint64_t total_items_allocated;
00055 uint64_t total_chunks_allocated;
00057 uint64_t total_chunks_freed;
00058 #endif
00059 };
00060 #endif
00061
00062 #endif
00063