lsquic_attq.h revision 50aadb33
1/* Copyright (c) 2017 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_attq.h -- Advisory Tick Time Queue 4 */ 5 6#ifndef LSQUIC_ATTQ_H 7#define LSQUIC_ATTQ_H 8 9struct attq; 10struct lsquic_conn; 11 12 13/* The extra level of indirection is done for speed: swapping heap elements 14 * does not need memory associated with lsquic_conn. 15 */ 16struct attq_elem 17{ 18 struct lsquic_conn *ae_conn; 19 lsquic_time_t ae_adv_time; 20 unsigned ae_heap_idx; 21}; 22 23 24struct attq * 25attq_create (void); 26 27void 28attq_destroy (struct attq *); 29 30/* Return 1 if advisory_time is too small, 0 on success, -1 on failure */ 31int 32attq_maybe_add (struct attq *, struct lsquic_conn *, 33 lsquic_time_t advisory_time); 34 35/* Return 0 on success, -1 on failure (malloc) */ 36int 37attq_add (struct attq *, struct lsquic_conn *, lsquic_time_t advisory_time); 38 39void 40attq_remove (struct attq *, struct lsquic_conn *); 41 42struct lsquic_conn * 43attq_pop (struct attq *, lsquic_time_t cutoff); 44 45unsigned 46attq_count_before (struct attq *, lsquic_time_t cutoff); 47 48const lsquic_time_t * 49attq_next_time (struct attq *); 50 51lsquic_time_t 52attq_set_min (struct attq *, lsquic_time_t new_min); 53 54#endif 55