* and insert it back into a slab allocator.
*/
finished:
- if (request->time_order_id >= 0) (void) fr_heap_extract(worker->time_order, request);
- if (request->runnable_id >= 0) (void) fr_heap_extract(worker->runnable, request);
+ if (fr_heap_entry_inserted(request->time_order_id)) (void) fr_heap_extract(worker->time_order, request);
+ if (fr_heap_entry_inserted(request->runnable_id)) (void) fr_heap_extract(worker->runnable, request);
- fr_assert(request->time_order_id < 0);
- fr_assert(request->runnable_id < 0);
+ fr_assert(!fr_heap_entry_inserted(request->time_order_id));
+ fr_assert(!fr_heap_entry_inserted(request->runnable_id));
#ifndef NDEBUG
request->async->el = NULL;
* strict time priority. Once they are in the list, they
* are only removed when the request is done / free'd.
*/
- fr_assert(request->time_order_id < 0);
+ fr_assert(!fr_heap_entry_inserted(request->time_order_id));
(void) fr_heap_insert(worker->time_order, request);
/*
*/
static int _request_free(request_t *request)
{
- fr_assert(request->time_order_id <= 0);
- fr_assert(request->runnable_id <= 0);
+ fr_assert(!fr_heap_entry_inserted(request->time_order_id));
+ fr_assert(!fr_heap_entry_inserted(request->runnable_id));
/*
* Reinsert into the free list if it's not already
fr_heap_t *_fr_heap_alloc(TALLOC_CTX *ctx, fr_heap_cmp_t cmp, char const *talloc_type, size_t offset);
+/** Check if an entry is inserted into a heap
+ *
+ */
+static inline bool fr_heap_entry_inserted(int32_t heap_id)
+{
+ return (heap_id >= 0);
+}
+
int fr_heap_insert(fr_heap_t *hp, void *data) CC_HINT(nonnull);
int fr_heap_extract(fr_heap_t *hp, void *data) CC_HINT(nonnull(1));
void *fr_heap_pop(fr_heap_t *hp) CC_HINT(nonnull);