feat(cat-heap): initial implementation

This commit is contained in:
Jef Roosens 2023-03-07 12:43:31 +01:00 committed by Jef Roosens
parent 1c563d8421
commit 8e076f8543
7 changed files with 183 additions and 0 deletions

30
include/vieter_cat_heap.h Normal file
View file

@ -0,0 +1,30 @@
#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);
#endif

View file

@ -123,5 +123,22 @@ vieter_job_queue_remove(vieter_job **out, vieter_job_queue *queue, uint64_t id);
*/
vieter_job_queue_error vieter_job_queue_fail(vieter_job_queue *queue,
uint64_t id, char *report_message);
/*
* Acquire a read lock on the job queue. Return value is the result of
* pthread_rwlock_rdlock.
*/
int vieter_job_queue_rlock(vieter_job_queue *job_queue);
/*
* Acquire a write lock on the job queue. Return value is the result of
* pthread_rwlock_wrlock.
*/
int vieter_job_queue_wlock(vieter_job_queue *job_queue);
/*
* Unlock the lock after having acquired it. Return value is the result of
* pthread_rwlock_unlock.
*/
int vieter_job_queue_unlock(vieter_job_queue *job_queue);
#endif