lsquic_spi.h revision 7d09751d
1/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_spi.h - SPI: Stream Priority Iterator 4 * 5 * SPI purposefully does not support switching stream priorities while 6 * iterator is active, because this puts iteration termination outside 7 * of our control. One can imagine (admittedly theoretical) scenario 8 * in which the user keeps on switching stream priorities around and 9 * causing an infinite loop. 10 */ 11 12#ifndef LSQUIC_SPI 13#define LSQUIC_SPI 1 14 15#include <stdint.h> 16 17enum stream_q_flags; 18 19 20struct stream_prio_iter 21{ 22 const struct lsquic_conn *spi_conn; /* Used for logging */ 23 const char *spi_name; /* Used for logging */ 24 uint64_t spi_set[4]; /* 256 bits */ 25 enum stream_q_flags spi_onlist_mask; 26 unsigned spi_n_added; 27 unsigned char spi_cur_prio; 28 unsigned char spi_prev_prio; 29 struct lsquic_stream *spi_prev_stream, 30 *spi_next_stream; 31 struct lsquic_streams_tailq spi_streams[256]; 32}; 33 34 35void 36lsquic_spi_init (struct stream_prio_iter *, struct lsquic_stream *first, 37 struct lsquic_stream *last, uintptr_t next_ptr_offset, 38 enum stream_q_flags onlist_mask, const struct lsquic_conn *, 39 const char *name, 40 int (*filter)(void *filter_ctx, struct lsquic_stream *), 41 void *filter_ctx); 42 43struct lsquic_stream * 44lsquic_spi_first (struct stream_prio_iter *); 45 46struct lsquic_stream * 47lsquic_spi_next (struct stream_prio_iter *); 48 49void 50lsquic_spi_exhaust_on (struct stream_prio_iter *); 51 52void 53lsquic_spi_drop_non_high (struct stream_prio_iter *); 54 55void 56lsquic_spi_drop_high (struct stream_prio_iter *); 57 58#endif 59