feat(heap): thread-safety features
This commit is contained in:
parent
d77b3e4fee
commit
5b2ce6acaa
4 changed files with 41 additions and 3 deletions
|
|
@ -11,7 +11,7 @@ typedef enum vieter_heap_error {
|
|||
} vieter_heap_error;
|
||||
|
||||
/*
|
||||
* Allocate and initalize an empty heap.
|
||||
* Allocate and initialize an empty heap.
|
||||
*/
|
||||
vieter_heap *vieter_heap_init();
|
||||
|
||||
|
|
@ -41,4 +41,22 @@ vieter_heap_error vieter_heap_pop(void **out, vieter_heap *heap);
|
|||
*/
|
||||
vieter_heap_error vieter_heap_peek(void **out, vieter_heap *heap);
|
||||
|
||||
/*
|
||||
* Acquire a read lock on the heap. Return value is the result of
|
||||
* pthread_rwlock_rdlock.
|
||||
*/
|
||||
int vieter_heap_rlock(vieter_heap *heap);
|
||||
|
||||
/*
|
||||
* Acquire a write lock on the heap. Return value is the result of
|
||||
* pthread_rwlock_wrlock.
|
||||
*/
|
||||
int vieter_heap_wlock(vieter_heap *heap);
|
||||
|
||||
/*
|
||||
* Unlock the lock after having acquired it. Return value is the result of
|
||||
* pthread_rwlock_unlock.
|
||||
*/
|
||||
int vieter_heap_unlock(vieter_heap *heap);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Reference in a new issue