fix ordering on stream wakeups
Change-Id: I1b00f15d874285195b2f70c9cf5f0e242c501d96
diff --git a/src/stream.rs b/src/stream.rs
index 696e2a6..6664398 100644
--- a/src/stream.rs
+++ b/src/stream.rs
@@ -27,6 +27,7 @@
use std::cmp;
use std::collections::hash_map;
+use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
@@ -88,19 +89,19 @@
/// Set of stream IDs corresponding to streams that have outstanding data
/// to read. This is used to generate a `StreamIter` of streams without
/// having to iterate over the full list of streams.
- readable: HashSet<u64>,
+ readable: BTreeSet<u64>,
/// Set of stream IDs corresponding to streams that have enough flow control
/// capacity to be written to, and is not finished. This is used to generate
/// a `StreamIter` of streams without having to iterate over the full list
/// of streams.
- writable: HashSet<u64>,
+ writable: BTreeSet<u64>,
/// Set of stream IDs corresponding to streams that are almost out of flow
/// control credit and need to send MAX_STREAM_DATA. This is used to
/// generate a `StreamIter` of streams without having to iterate over the
/// full list of streams.
- almost_full: HashSet<u64>,
+ almost_full: BTreeSet<u64>,
/// Set of stream IDs corresponding to streams that are blocked. The value
/// of the map elements represents the offset of the stream at which the
@@ -511,9 +512,9 @@
}
impl StreamIter {
- fn from(streams: &HashSet<u64>) -> Self {
+ fn from(streams: &BTreeSet<u64>) -> Self {
StreamIter {
- streams: streams.iter().copied().collect(),
+ streams: streams.iter().rev().copied().collect(),
}
}
}