lsquic_attq.h revision 229fce07
1229fce07SDmitri Tikhonov/* Copyright (c) 2017 - 2019 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 0 on success, -1 on failure (malloc) */
3150aadb33SDmitri Tikhonovint
3250aadb33SDmitri Tikhonovattq_add (struct attq *, struct lsquic_conn *, lsquic_time_t advisory_time);
3350aadb33SDmitri Tikhonov
3450aadb33SDmitri Tikhonovvoid
3550aadb33SDmitri Tikhonovattq_remove (struct attq *, struct lsquic_conn *);
3650aadb33SDmitri Tikhonov
3750aadb33SDmitri Tikhonovstruct lsquic_conn *
3850aadb33SDmitri Tikhonovattq_pop (struct attq *, lsquic_time_t cutoff);
3950aadb33SDmitri Tikhonov
4050aadb33SDmitri Tikhonovunsigned
4150aadb33SDmitri Tikhonovattq_count_before (struct attq *, lsquic_time_t cutoff);
4250aadb33SDmitri Tikhonov
4350aadb33SDmitri Tikhonovconst lsquic_time_t *
4450aadb33SDmitri Tikhonovattq_next_time (struct attq *);
4550aadb33SDmitri Tikhonov
4650aadb33SDmitri Tikhonov#endif
47