lsquic_min_heap.h revision 229fce07
1229fce07SDmitri Tikhonov/* Copyright (c) 2017 - 2019 LiteSpeed Technologies Inc. See LICENSE. */ 2e8bd737dSDmitri Tikhonov/* 3e8bd737dSDmitri Tikhonov * lsquic_min_heap.h -- Min-heap for connections 4e8bd737dSDmitri Tikhonov */ 5e8bd737dSDmitri Tikhonov 6e8bd737dSDmitri Tikhonov#ifndef LSQUIC_MIN_HEAP_H 7e8bd737dSDmitri Tikhonov#define LSQUIC_MIN_HEAP_H 1 8e8bd737dSDmitri Tikhonov 9e8bd737dSDmitri Tikhonovstruct lsquic_conn; 10e8bd737dSDmitri Tikhonov 11e8bd737dSDmitri Tikhonovstruct min_heap_elem 12e8bd737dSDmitri Tikhonov{ 13e8bd737dSDmitri Tikhonov struct lsquic_conn *mhe_conn; 14e8bd737dSDmitri Tikhonov uint64_t mhe_val; 15e8bd737dSDmitri Tikhonov}; 16e8bd737dSDmitri Tikhonov 17e8bd737dSDmitri Tikhonov 18e8bd737dSDmitri Tikhonovstruct min_heap 19e8bd737dSDmitri Tikhonov{ 20e8bd737dSDmitri Tikhonov struct min_heap_elem *mh_elems; 21e8bd737dSDmitri Tikhonov unsigned mh_nalloc, 22e8bd737dSDmitri Tikhonov mh_nelem; 23e8bd737dSDmitri Tikhonov}; 24e8bd737dSDmitri Tikhonov 25e8bd737dSDmitri Tikhonov 26e8bd737dSDmitri Tikhonovvoid 27e8bd737dSDmitri Tikhonovlsquic_mh_insert (struct min_heap *, struct lsquic_conn *conn, uint64_t val); 28e8bd737dSDmitri Tikhonov 29e8bd737dSDmitri Tikhonovstruct lsquic_conn * 30e8bd737dSDmitri Tikhonovlsquic_mh_pop (struct min_heap *); 31e8bd737dSDmitri Tikhonov 32e8bd737dSDmitri Tikhonov#define lsquic_mh_count(heap) (+(heap)->mh_nelem) 33e8bd737dSDmitri Tikhonov 34e8bd737dSDmitri Tikhonov#define lsquic_mh_nalloc(heap) (+(heap)->mh_nalloc) 35e8bd737dSDmitri Tikhonov 36e8bd737dSDmitri Tikhonov#endif 37