lsquic_attq.h revision 50aadb33
150aadb33SDmitri Tikhonov/* Copyright (c) 2017 LiteSpeed Technologies Inc. See LICENSE. */ 250aadb33SDmitri Tikhonov/* 350aadb33SDmitri Tikhonov * lsquic_attq.h -- Advisory Tick Time Queue 450aadb33SDmitri Tikhonov */ 550aadb33SDmitri Tikhonov 650aadb33SDmitri Tikhonov#ifndef LSQUIC_ATTQ_H 750aadb33SDmitri Tikhonov#define LSQUIC_ATTQ_H 850aadb33SDmitri Tikhonov 950aadb33SDmitri Tikhonovstruct attq; 1050aadb33SDmitri Tikhonovstruct lsquic_conn; 1150aadb33SDmitri Tikhonov 1250aadb33SDmitri Tikhonov 1350aadb33SDmitri Tikhonov/* The extra level of indirection is done for speed: swapping heap elements 1450aadb33SDmitri Tikhonov * does not need memory associated with lsquic_conn. 1550aadb33SDmitri Tikhonov */ 1650aadb33SDmitri Tikhonovstruct attq_elem 1750aadb33SDmitri Tikhonov{ 1850aadb33SDmitri Tikhonov struct lsquic_conn *ae_conn; 1950aadb33SDmitri Tikhonov lsquic_time_t ae_adv_time; 2050aadb33SDmitri Tikhonov unsigned ae_heap_idx; 2150aadb33SDmitri Tikhonov}; 2250aadb33SDmitri Tikhonov 2350aadb33SDmitri Tikhonov 2450aadb33SDmitri Tikhonovstruct attq * 2550aadb33SDmitri Tikhonovattq_create (void); 2650aadb33SDmitri Tikhonov 2750aadb33SDmitri Tikhonovvoid 2850aadb33SDmitri Tikhonovattq_destroy (struct attq *); 2950aadb33SDmitri Tikhonov 3050aadb33SDmitri Tikhonov/* Return 1 if advisory_time is too small, 0 on success, -1 on failure */ 3150aadb33SDmitri Tikhonovint 3250aadb33SDmitri Tikhonovattq_maybe_add (struct attq *, struct lsquic_conn *, 3350aadb33SDmitri Tikhonov lsquic_time_t advisory_time); 3450aadb33SDmitri Tikhonov 3550aadb33SDmitri Tikhonov/* Return 0 on success, -1 on failure (malloc) */ 3650aadb33SDmitri Tikhonovint 3750aadb33SDmitri Tikhonovattq_add (struct attq *, struct lsquic_conn *, lsquic_time_t advisory_time); 3850aadb33SDmitri Tikhonov 3950aadb33SDmitri Tikhonovvoid 4050aadb33SDmitri Tikhonovattq_remove (struct attq *, struct lsquic_conn *); 4150aadb33SDmitri Tikhonov 4250aadb33SDmitri Tikhonovstruct lsquic_conn * 4350aadb33SDmitri Tikhonovattq_pop (struct attq *, lsquic_time_t cutoff); 4450aadb33SDmitri Tikhonov 4550aadb33SDmitri Tikhonovunsigned 4650aadb33SDmitri Tikhonovattq_count_before (struct attq *, lsquic_time_t cutoff); 4750aadb33SDmitri Tikhonov 4850aadb33SDmitri Tikhonovconst lsquic_time_t * 4950aadb33SDmitri Tikhonovattq_next_time (struct attq *); 5050aadb33SDmitri Tikhonov 5150aadb33SDmitri Tikhonovlsquic_time_t 5250aadb33SDmitri Tikhonovattq_set_min (struct attq *, lsquic_time_t new_min); 5350aadb33SDmitri Tikhonov 5450aadb33SDmitri Tikhonov#endif 55