forked from vieter-v/libvieter
49 lines
1.3 KiB
C
49 lines
1.3 KiB
C
#ifndef VIETER_CAT_HEAP
|
|
#define VIETER_CAT_HEAP
|
|
|
|
#include <stdint.h>
|
|
|
|
typedef struct vieter_cat_heap vieter_cat_heap;
|
|
|
|
typedef enum vieter_cat_heap_error {
|
|
vieter_cat_heap_ok = 0,
|
|
vieter_cat_heap_arch_empty = 1,
|
|
vieter_cat_heap_arch_not_found = 2
|
|
} vieter_cat_heap_error;
|
|
|
|
vieter_cat_heap *vieter_cat_heap_init();
|
|
|
|
void vieter_cat_heap_free(vieter_cat_heap **ptp);
|
|
|
|
uint64_t vieter_cat_heap_size(vieter_cat_heap *cheap);
|
|
|
|
vieter_cat_heap_error vieter_cat_heap_insert(vieter_cat_heap *cheap,
|
|
char *category, uint64_t key,
|
|
void *data);
|
|
|
|
vieter_cat_heap_error vieter_cat_heap_pop(void **out, vieter_cat_heap *cheap,
|
|
char *category);
|
|
|
|
vieter_cat_heap_error vieter_cat_heap_peek(void **out, vieter_cat_heap *cheap,
|
|
char *category);
|
|
|
|
/*
|
|
* Acquire a read lock on the heap. Return value is the result of
|
|
* pthread_rwlock_rdlock.
|
|
*/
|
|
int vieter_cat_heap_rlock(vieter_cat_heap *cheap);
|
|
|
|
/*
|
|
* Acquire a write lock on the heap. Return value is the result of
|
|
* pthread_rwlock_wrlock.
|
|
*/
|
|
int vieter_cat_heap_wlock(vieter_cat_heap *cheap);
|
|
|
|
/*
|
|
* Unlock the lock after having acquired it. Return value is the result of
|
|
* pthread_rwlock_unlock.
|
|
*/
|
|
int vieter_cat_heap_unlock(vieter_cat_heap *cheap);
|
|
|
|
#endif
|