00001
00012 #ifndef _TXC_POOL_H
00013 #define _TXC_POOL_H
00014
00015 #include <misc/result.h>
00016
00017 #define TXC_POOL_OBJECT_FREE 0x1
00018 #define TXC_POOL_OBJECT_ALLOCATED 0x2
00019
00028 typedef struct txc_pool_object_s txc_pool_object_t;
00029 typedef struct txc_pool_s txc_pool_t;
00030 typedef void (*txc_pool_object_constructor_t)(void *obj);
00031 typedef void (*txc_pool_object_print_t)(void *obj);
00032
00033 txc_result_t txc_pool_create(txc_pool_t **poolp,
00034 unsigned int obj_size,
00035 unsigned int obj_num,
00036 txc_pool_object_constructor_t obj_constructor);
00037 txc_result_t txc_pool_destroy(txc_pool_t **poolp);
00038 txc_result_t txc_pool_object_alloc(txc_pool_t *pool, void **objp, int lock);
00039 void txc_pool_object_free(txc_pool_t *pool, void **objp, int lock);
00040 txc_pool_object_t *txc_pool_object_first(txc_pool_t *pool, int obj_status);
00041 txc_pool_object_t *txc_pool_object_next(txc_pool_object_t *obj);
00042 void *txc_pool_object_of(txc_pool_object_t *obj);
00043 void txc_pool_lock(txc_pool_t *pool);
00044 void txc_pool_unlock(txc_pool_t *pool);
00045 void txc_pool_print(txc_pool_t *pool, txc_pool_object_print_t printer, int verbose);
00046
00047 #endif