#ifndef UCX_MEMPOOL_H
#define UCX_MEMPOOL_H
#include "common.h"
#include "allocator.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct cx_mempool_class_s cx_mempool_class;
struct cx_mempool_s {
cx_mempool_class *cl;
CxAllocator
const *allocator;
};
typedef struct cx_mempool_s CxMempool;
struct cx_mempool_class_s {
__attribute__((__nonnull__))
void (*destroy)(CxMempool *pool);
__attribute__((__nonnull__))
void (*set_destructor)(
CxMempool *pool,
void *memory,
cx_destructor_func fnc
);
};
__attribute__((__nonnull__))
static inline
void cxMempoolDestroy(CxMempool *pool) {
pool->cl->destroy(pool);
}
__attribute__((__nonnull__))
static inline
void cxMempoolSetDestructor(
CxMempool *pool,
void *memory,
cx_destructor_func fnc
) {
pool->cl->set_destructor(pool, memory, fnc);
}
#ifdef __cplusplus
}
#endif
#endif