ucx/mempool.h

changeset 2
eeb50c534497
parent 0
1f419bd32da1
child 124
80609f9675f1
equal deleted inserted replaced
1:eb5269000bc8 2:eeb50c534497
55 55
56 /** 56 /**
57 * UCX mempool structure. 57 * UCX mempool structure.
58 */ 58 */
59 typedef struct { 59 typedef struct {
60 /** UcxAllocator based on this pool */
61 UcxAllocator *allocator;
62
60 /** List of pointers to pooled memory. */ 63 /** List of pointers to pooled memory. */
61 void **data; 64 void **data;
62 65
63 /** Count of pooled memory items. */ 66 /** Count of pooled memory items. */
64 size_t ndata; 67 size_t ndata;
65 68
66 /** Memory pool size. */ 69 /** Memory pool size. */
67 size_t size; 70 size_t size;
68 } UcxMempool; 71 } UcxMempool;
69 72
70 /** Shorthand for a new default memory pool with a capacity of 16 elements. */ 73 /** Shorthand for a new default memory pool with a capacity of 16 elements. */
71 #define ucx_mempool_new_default() ucx_mempool_new(16) 74 #define ucx_mempool_new_default() ucx_mempool_new(16)
72 75
208 * @param ptr data the destructor is registered for 211 * @param ptr data the destructor is registered for
209 * @param destr a pointer to the destructor function 212 * @param destr a pointer to the destructor function
210 */ 213 */
211 void ucx_mempool_reg_destr(UcxMempool *pool, void *ptr, ucx_destructor destr); 214 void ucx_mempool_reg_destr(UcxMempool *pool, void *ptr, ucx_destructor destr);
212 215
213 /**
214 * Creates an UcxAllocator based on an UcxMempool.
215 *
216 * @param pool the mempool to create the UcxAllocator for
217 * @return a new UcxAllocator based on the specified pool
218 */
219 UcxAllocator* ucx_mempool_allocator(UcxMempool *pool);
220
221 #ifdef __cplusplus 216 #ifdef __cplusplus
222 } 217 }
223 #endif 218 #endif
224 219
225 #endif /* UCX_MEMPOOL_H */ 220 #endif /* UCX_MEMPOOL_H */

mercurial