lsquic_attq.h revision a74702c6
1a74702c6SGeorge Wang/* Copyright (c) 2017 - 2022 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; 210adf085aSDmitri Tikhonov /* The "why" describes why the connection is in the Advisory Tick Time 220adf085aSDmitri Tikhonov * Queue. Values past the range describe different alarm types (see 230adf085aSDmitri Tikhonov * enum alarm_id). 240adf085aSDmitri Tikhonov */ 250adf085aSDmitri Tikhonov enum ae_why { 260adf085aSDmitri Tikhonov AEW_PACER, 270adf085aSDmitri Tikhonov AEW_MINI_EXPIRE, 280adf085aSDmitri Tikhonov N_AEWS 290adf085aSDmitri Tikhonov } ae_why; 3050aadb33SDmitri Tikhonov}; 3150aadb33SDmitri Tikhonov 3250aadb33SDmitri Tikhonov 3350aadb33SDmitri Tikhonovstruct attq * 34a5fa05f9SDmitri Tikhonovlsquic_attq_create (void); 3550aadb33SDmitri Tikhonov 3650aadb33SDmitri Tikhonovvoid 37a5fa05f9SDmitri Tikhonovlsquic_attq_destroy (struct attq *); 3850aadb33SDmitri Tikhonov 3950aadb33SDmitri Tikhonov/* Return 0 on success, -1 on failure (malloc) */ 4050aadb33SDmitri Tikhonovint 41a5fa05f9SDmitri Tikhonovlsquic_attq_add (struct attq *, struct lsquic_conn *, lsquic_time_t advisory_time, 420adf085aSDmitri Tikhonov enum ae_why); 4350aadb33SDmitri Tikhonov 4450aadb33SDmitri Tikhonovvoid 45a5fa05f9SDmitri Tikhonovlsquic_attq_remove (struct attq *, struct lsquic_conn *); 4650aadb33SDmitri Tikhonov 4750aadb33SDmitri Tikhonovstruct lsquic_conn * 48a5fa05f9SDmitri Tikhonovlsquic_attq_pop (struct attq *, lsquic_time_t cutoff); 4950aadb33SDmitri Tikhonov 5050aadb33SDmitri Tikhonovunsigned 51a5fa05f9SDmitri Tikhonovlsquic_attq_count_before (struct attq *, lsquic_time_t cutoff); 5250aadb33SDmitri Tikhonov 530adf085aSDmitri Tikhonovconst struct attq_elem * 54a5fa05f9SDmitri Tikhonovlsquic_attq_next (struct attq *); 550adf085aSDmitri Tikhonov 560adf085aSDmitri Tikhonovconst char * 570adf085aSDmitri Tikhonovlsquic_attq_why2str (enum ae_why); 5850aadb33SDmitri Tikhonov 5950aadb33SDmitri Tikhonov#endif 60