lsquic_spi.h revision 229fce07
1/* Copyright (c) 2017 - 2019 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 17 18struct stream_prio_iter 19{ 20 lsquic_cid_t spi_cid; /* Used for logging */ 21 const char *spi_name; /* Used for logging */ 22 uint64_t spi_set[4]; /* 256 bits */ 23 enum stream_flags spi_onlist_mask; 24 unsigned char spi_cur_prio; 25 unsigned char spi_prev_prio; 26 struct lsquic_stream *spi_prev_stream, 27 *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 unsigned onlist_mask, lsquic_cid_t cid, const char *name); 36 37struct lsquic_stream * 38lsquic_spi_first (struct stream_prio_iter *); 39 40struct lsquic_stream * 41lsquic_spi_next (struct stream_prio_iter *); 42 43void 44lsquic_spi_exhaust_on (struct stream_prio_iter *); 45 46void 47lsquic_spi_drop_non_high (struct stream_prio_iter *); 48 49void 50lsquic_spi_drop_high (struct stream_prio_iter *); 51 52#endif 53