fix(rustup): update lifetime bounds
Send no longer implies 'static; update needed lifetime bounds.
This commit is contained in:
committed by
Sean McArthur
parent
e8833c0c89
commit
f4a66b38cb
@@ -22,7 +22,7 @@ impl<S: Scheme> DerefMut for Authorization<S> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Scheme> Header for Authorization<S> {
|
impl<S: Scheme + 'static> Header for Authorization<S> {
|
||||||
fn header_name() -> &'static str {
|
fn header_name() -> &'static str {
|
||||||
"Authorization"
|
"Authorization"
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ impl<S: Scheme> Header for Authorization<S> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Scheme> HeaderFormat for Authorization<S> {
|
impl<S: Scheme + 'static> HeaderFormat for Authorization<S> {
|
||||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match Scheme::scheme(None::<S>) {
|
match Scheme::scheme(None::<S>) {
|
||||||
Some(scheme) => try!(write!(fmt, "{} ", scheme)),
|
Some(scheme) => try!(write!(fmt, "{} ", scheme)),
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ pub trait NetworkAcceptor: Clone + Send {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator wrapper over a NetworkAcceptor.
|
/// An iterator wrapper over a NetworkAcceptor.
|
||||||
pub struct NetworkConnections<'a, N: NetworkAcceptor>(&'a mut N);
|
pub struct NetworkConnections<'a, N: NetworkAcceptor + 'a>(&'a mut N);
|
||||||
|
|
||||||
impl<'a, N: NetworkAcceptor> Iterator for NetworkConnections<'a, N> {
|
impl<'a, N: NetworkAcceptor> Iterator for NetworkConnections<'a, N> {
|
||||||
type Item = IoResult<N::Stream>;
|
type Item = IoResult<N::Stream>;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ pub struct AcceptorPool<A: NetworkAcceptor> {
|
|||||||
acceptor: A
|
acceptor: A
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A: NetworkAcceptor> AcceptorPool<A> {
|
impl<A: NetworkAcceptor + 'static> AcceptorPool<A> {
|
||||||
/// Create a thread pool to manage the acceptor.
|
/// Create a thread pool to manage the acceptor.
|
||||||
pub fn new(acceptor: A) -> AcceptorPool<A> {
|
pub fn new(acceptor: A) -> AcceptorPool<A> {
|
||||||
AcceptorPool { acceptor: acceptor }
|
AcceptorPool { acceptor: acceptor }
|
||||||
@@ -18,9 +18,8 @@ impl<A: NetworkAcceptor> AcceptorPool<A> {
|
|||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
/// Panics if threads == 0.
|
/// Panics if threads == 0.
|
||||||
pub fn accept<F: Fn(A::Stream) + Send + Sync>(self,
|
pub fn accept<F>(self, work: F, threads: usize) -> JoinGuard<'static, ()>
|
||||||
work: F,
|
where F: Fn(A::Stream) + Send + Sync + 'static {
|
||||||
threads: usize) -> JoinGuard<'static, ()> {
|
|
||||||
assert!(threads != 0, "Can't accept on 0 threads.");
|
assert!(threads != 0, "Can't accept on 0 threads.");
|
||||||
|
|
||||||
// Replace with &F when Send changes land.
|
// Replace with &F when Send changes land.
|
||||||
@@ -40,8 +39,8 @@ impl<A: NetworkAcceptor> AcceptorPool<A> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_with<A, F>(supervisor: mpsc::Sender<()>, work: Arc<F>, mut acceptor: A)
|
fn spawn_with<A, F>(supervisor: mpsc::Sender<()>, work: Arc<F>, mut acceptor: A)
|
||||||
where A: NetworkAcceptor,
|
where A: NetworkAcceptor + 'static,
|
||||||
F: Fn(<A as NetworkAcceptor>::Stream) + Send + Sync {
|
F: Fn(<A as NetworkAcceptor>::Stream) + Send + Sync + 'static {
|
||||||
use std::old_io::EndOfFile;
|
use std::old_io::EndOfFile;
|
||||||
|
|
||||||
Thread::spawn(move || {
|
Thread::spawn(move || {
|
||||||
@@ -83,7 +82,7 @@ impl<T: Send> Sentinel<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[unsafe_destructor]
|
#[unsafe_destructor]
|
||||||
impl<T: Send> Drop for Sentinel<T> {
|
impl<T: Send + 'static> Drop for Sentinel<T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// If we were cancelled, get out of here.
|
// If we were cancelled, get out of here.
|
||||||
if !self.active { return; }
|
if !self.active { return; }
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ impl Server<HttpListener> {
|
|||||||
|
|
||||||
impl<
|
impl<
|
||||||
L: NetworkListener<Acceptor=A> + Send,
|
L: NetworkListener<Acceptor=A> + Send,
|
||||||
A: NetworkAcceptor<Stream=S> + Send,
|
A: NetworkAcceptor<Stream=S> + Send + 'static,
|
||||||
S: NetworkStream + Clone + Send> Server<L> {
|
S: NetworkStream + Clone + Send> Server<L> {
|
||||||
/// Creates a new server that will handle `HttpStream`s.
|
/// Creates a new server that will handle `HttpStream`s.
|
||||||
pub fn with_listener(ip: IpAddr, port: Port, listener: L) -> Server<L> {
|
pub fn with_listener(ip: IpAddr, port: Port, listener: L) -> Server<L> {
|
||||||
@@ -68,7 +68,7 @@ S: NetworkStream + Clone + Send> Server<L> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Binds to a socket, and starts handling connections using a task pool.
|
/// Binds to a socket, and starts handling connections using a task pool.
|
||||||
pub fn listen_threads<H: Handler>(mut self, handler: H, threads: usize) -> HttpResult<Listening<L::Acceptor>> {
|
pub fn listen_threads<H: Handler + 'static>(mut self, handler: H, threads: usize) -> HttpResult<Listening<L::Acceptor>> {
|
||||||
debug!("binding to {:?}:{:?}", self.ip, self.port);
|
debug!("binding to {:?}:{:?}", self.ip, self.port);
|
||||||
let acceptor = try!(self.listener.listen((self.ip, self.port)));
|
let acceptor = try!(self.listener.listen((self.ip, self.port)));
|
||||||
let socket = try!(acceptor.socket_name());
|
let socket = try!(acceptor.socket_name());
|
||||||
@@ -85,7 +85,7 @@ S: NetworkStream + Clone + Send> Server<L> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Binds to a socket and starts handling connections.
|
/// Binds to a socket and starts handling connections.
|
||||||
pub fn listen<H: Handler>(self, handler: H) -> HttpResult<Listening<L::Acceptor>> {
|
pub fn listen<H: Handler + 'static>(self, handler: H) -> HttpResult<Listening<L::Acceptor>> {
|
||||||
self.listen_threads(handler, os::num_cpus() * 5 / 4)
|
self.listen_threads(handler, os::num_cpus() * 5 / 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user