lsquic_attq.h revision 7d09751d
1/* Copyright (c) 2017 - 2020 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 /* The "why" describes why the connection is in the Advisory Tick Time 22 * Queue. Values past the range describe different alarm types (see 23 * enum alarm_id). 24 */ 25 enum ae_why { 26 AEW_PACER, 27 AEW_MINI_EXPIRE, 28 N_AEWS 29 } ae_why; 30}; 31 32 33struct attq * 34attq_create (void); 35 36void 37attq_destroy (struct attq *); 38 39/* Return 0 on success, -1 on failure (malloc) */ 40int 41attq_add (struct attq *, struct lsquic_conn *, lsquic_time_t advisory_time, 42 enum ae_why); 43 44void 45attq_remove (struct attq *, struct lsquic_conn *); 46 47struct lsquic_conn * 48attq_pop (struct attq *, lsquic_time_t cutoff); 49 50unsigned 51attq_count_before (struct attq *, lsquic_time_t cutoff); 52 53const struct attq_elem * 54attq_next (struct attq *); 55 56const char * 57lsquic_attq_why2str (enum ae_why); 58 59#endif 60