Wire in recv flow control (#26)

This commit is contained in:
Carl Lerche
2017-08-23 11:22:24 -07:00
committed by GitHub
parent a623ab68b5
commit 807d2b7317
18 changed files with 452 additions and 345 deletions

View File

@@ -108,53 +108,4 @@ impl<B> Deque<B> {
None => None,
}
}
pub fn take_while<F>(&mut self, buf: &mut Buffer<B>, mut f: F) -> Self
where F: FnMut(&Frame<B>) -> bool
{
match self.indices {
Some(mut idxs) => {
if !f(&buf.slab[idxs.head].frame) {
return Deque::new();
}
let head = idxs.head;
let mut tail = idxs.head;
loop {
let next = match buf.slab[tail].next {
Some(next) => next,
None => {
self.indices = None;
return Deque {
indices: Some(idxs),
_p: PhantomData,
};
}
};
if !f(&buf.slab[next].frame) {
// Split the linked list
buf.slab[tail].next = None;
self.indices = Some(Indices {
head: next,
tail: idxs.tail,
});
return Deque {
indices: Some(Indices {
head: head,
tail: tail,
}),
_p: PhantomData,
}
}
tail = next;
}
}
None => Deque::new(),
}
}
}