lsquic_spi.h revision cd35ff02
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 unsigned spi_n_added; 26 unsigned char spi_cur_prio; 27 struct lsquic_stream *spi_next_stream; 28 struct lsquic_streams_tailq spi_streams[256]; 29}; 30 31 32void 33lsquic_spi_init (struct stream_prio_iter *, struct lsquic_stream *first, 34 struct lsquic_stream *last, uintptr_t next_ptr_offset, 35 const struct lsquic_conn *, 36 const char *name, 37 int (*filter)(void *filter_ctx, struct lsquic_stream *), 38 void *filter_ctx); 39 40struct lsquic_stream * 41lsquic_spi_first (struct stream_prio_iter *); 42 43struct lsquic_stream * 44lsquic_spi_next (struct stream_prio_iter *); 45 46void 47lsquic_spi_exhaust_on (struct stream_prio_iter *); 48 49void 50lsquic_spi_drop_non_high (struct stream_prio_iter *); 51 52void 53lsquic_spi_drop_high (struct stream_prio_iter *); 54 55#endif 56