1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 01:32:57 +01:00

Make Node's traverse method take a closure instead of calling shutdown on each HttpChannel.

This commit is contained in:
Robert G. Jakabosky 2018-09-10 01:51:03 +08:00
parent e0ae6b10cd
commit 70b45659e2
2 changed files with 4 additions and 4 deletions

View File

@ -55,7 +55,7 @@ where
}
}
fn shutdown(&mut self) {
pub(crate) fn shutdown(&mut self) {
match self.proto {
Some(HttpProtocol::H1(ref mut h1)) => {
let io = h1.io();
@ -232,7 +232,7 @@ impl Node<()> {
}
}
pub(crate) fn traverse<T, H>(&self)
pub(crate) fn traverse<T, H, F: Fn(&mut HttpChannel<T, H>)>(&self, f: F)
where
T: IoStream,
H: HttpHandler + 'static,
@ -247,7 +247,7 @@ impl Node<()> {
if !n.element.is_null() {
let ch: &mut HttpChannel<T, H> =
&mut *(&mut *(n.element as *mut _) as *mut () as *mut _);
ch.shutdown();
f(ch);
}
}
} else {

View File

@ -637,7 +637,7 @@ where
fn shutdown(&self, force: bool) {
if force {
self.settings.head().traverse::<TcpStream, H>();
self.settings.head().traverse(|ch: &mut HttpChannel<TcpStream, H>| ch.shutdown());
}
}
}