lsquic_attq.h revision 7d09751d
17d09751dSDmitri Tikhonov/* Copyright (c) 2017 - 2020 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 *
3450aadb33SDmitri Tikhonovattq_create (void);
3550aadb33SDmitri Tikhonov
3650aadb33SDmitri Tikhonovvoid
3750aadb33SDmitri Tikhonovattq_destroy (struct attq *);
3850aadb33SDmitri Tikhonov
3950aadb33SDmitri Tikhonov/* Return 0 on success, -1 on failure (malloc) */
4050aadb33SDmitri Tikhonovint
410adf085aSDmitri Tikhonovattq_add (struct attq *, struct lsquic_conn *, lsquic_time_t advisory_time,
420adf085aSDmitri Tikhonov                enum ae_why);
4350aadb33SDmitri Tikhonov
4450aadb33SDmitri Tikhonovvoid
4550aadb33SDmitri Tikhonovattq_remove (struct attq *, struct lsquic_conn *);
4650aadb33SDmitri Tikhonov
4750aadb33SDmitri Tikhonovstruct lsquic_conn *
4850aadb33SDmitri Tikhonovattq_pop (struct attq *, lsquic_time_t cutoff);
4950aadb33SDmitri Tikhonov
5050aadb33SDmitri Tikhonovunsigned
5150aadb33SDmitri Tikhonovattq_count_before (struct attq *, lsquic_time_t cutoff);
5250aadb33SDmitri Tikhonov
530adf085aSDmitri Tikhonovconst struct attq_elem *
540adf085aSDmitri Tikhonovattq_next (struct attq *);
550adf085aSDmitri Tikhonov
560adf085aSDmitri Tikhonovconst char *
570adf085aSDmitri Tikhonovlsquic_attq_why2str (enum ae_why);
5850aadb33SDmitri Tikhonov
5950aadb33SDmitri Tikhonov#endif
60