lsquic_spi.h revision 50aadb33
1/* Copyright (c) 2017 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 spi_flags { 18 SPI_EXHAUST_PRIO = (1 << 0), /* Exhaust priority level before moving on */ 19}; 20 21 22struct stream_prio_iter 23{ 24 lsquic_cid_t spi_cid; /* Used for logging */ 25 const char *spi_name; /* Used for logging */ 26 uint64_t spi_set[4]; /* 256 bits */ 27 enum stream_flags spi_onlist_mask; 28 enum spi_flags spi_flags:8; 29 unsigned char spi_cur_prio; 30 unsigned char spi_prev_prio; 31 struct lsquic_stream *spi_prev_stream, 32 *spi_next_stream; 33 struct lsquic_streams_tailq spi_streams[256]; 34}; 35 36 37void 38lsquic_spi_init_ext (struct stream_prio_iter *, struct lsquic_stream *first, 39 struct lsquic_stream *last, uintptr_t next_ptr_offset, 40 unsigned onlist_mask, int (*filter)(void *, struct lsquic_stream *), 41 void *filter_ctx, lsquic_cid_t cid, const char *name); 42 43#define lsquic_spi_init(spi, first, last, off, mask, cid, name) \ 44 lsquic_spi_init_ext(spi, first, last, off, mask, NULL, NULL, cid, name) 45 46#define lsquic_spi_init_simple(spi, first, last, off, mask) \ 47 lsquic_spi_init(spi, first, last, off, mask, 0, NULL) 48 49struct lsquic_stream * 50lsquic_spi_first (struct stream_prio_iter *); 51 52struct lsquic_stream * 53lsquic_spi_next (struct stream_prio_iter *); 54 55void 56lsquic_spi_exhaust_on (struct stream_prio_iter *); 57 58#endif 59