feat(server): keep-alive!
Internals have been shuffled around such that Request and Reponse are now given only a mutable reference to the stream, instead of being allowed to consume it. This allows the server to re-use the streams if keep-alive is true. A task pool is used, and the number of the threads can currently be adjusted by using the `listen_threads()` method on Server. [breaking-change]
This commit is contained in:
13
src/net.rs
13
src/net.rs
@@ -82,6 +82,19 @@ impl Writer for Box<NetworkStream + Send> {
|
||||
fn flush(&mut self) -> IoResult<()> { (**self).flush() }
|
||||
}
|
||||
|
||||
impl<'a> Reader for &'a mut NetworkStream {
|
||||
#[inline]
|
||||
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { (**self).read(buf) }
|
||||
}
|
||||
|
||||
impl<'a> Writer for &'a mut NetworkStream {
|
||||
#[inline]
|
||||
fn write(&mut self, msg: &[u8]) -> IoResult<()> { (**self).write(msg) }
|
||||
|
||||
#[inline]
|
||||
fn flush(&mut self) -> IoResult<()> { (**self).flush() }
|
||||
}
|
||||
|
||||
impl UncheckedBoxAnyDowncast for Box<NetworkStream + Send> {
|
||||
unsafe fn downcast_unchecked<T: 'static>(self) -> Box<T> {
|
||||
let to = *mem::transmute::<&Box<NetworkStream + Send>, &raw::TraitObject>(&self);
|
||||
|
||||
Reference in New Issue
Block a user