Skip to content

Commit

Permalink
fix(rustup): update lifetime bounds
Browse files Browse the repository at this point in the history
Send no longer implies 'static; update needed lifetime bounds.
  • Loading branch information
renato-zannon authored and seanmonstar committed Feb 21, 2015
1 parent e8833c0 commit f4a66b3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/header/common/authorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
"Authorization"
}
Expand All @@ -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 {
match Scheme::scheme(None::<S>) {
Some(scheme) => try!(write!(fmt, "{} ", scheme)),
Expand Down
2 changes: 1 addition & 1 deletion src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub trait NetworkAcceptor: Clone + Send {
}

/// 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> {
type Item = IoResult<N::Stream>;
Expand Down
13 changes: 6 additions & 7 deletions src/server/acceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct AcceptorPool<A: NetworkAcceptor> {
acceptor: A
}

impl<A: NetworkAcceptor> AcceptorPool<A> {
impl<A: NetworkAcceptor + 'static> AcceptorPool<A> {
/// Create a thread pool to manage the acceptor.
pub fn new(acceptor: A) -> AcceptorPool<A> {
AcceptorPool { acceptor: acceptor }
Expand All @@ -18,9 +18,8 @@ impl<A: NetworkAcceptor> AcceptorPool<A> {
/// ## Panics
///
/// Panics if threads == 0.
pub fn accept<F: Fn(A::Stream) + Send + Sync>(self,
work: F,
threads: usize) -> JoinGuard<'static, ()> {
pub fn accept<F>(self, work: F, threads: usize) -> JoinGuard<'static, ()>
where F: Fn(A::Stream) + Send + Sync + 'static {
assert!(threads != 0, "Can't accept on 0 threads.");

// Replace with &F when Send changes land.
Expand All @@ -40,8 +39,8 @@ impl<A: NetworkAcceptor> AcceptorPool<A> {
}

fn spawn_with<A, F>(supervisor: mpsc::Sender<()>, work: Arc<F>, mut acceptor: A)
where A: NetworkAcceptor,
F: Fn(<A as NetworkAcceptor>::Stream) + Send + Sync {
where A: NetworkAcceptor + 'static,
F: Fn(<A as NetworkAcceptor>::Stream) + Send + Sync + 'static {
use std::old_io::EndOfFile;

Thread::spawn(move || {
Expand Down Expand Up @@ -83,7 +82,7 @@ impl<T: Send> Sentinel<T> {
}

#[unsafe_destructor]
impl<T: Send> Drop for Sentinel<T> {
impl<T: Send + 'static> Drop for Sentinel<T> {
fn drop(&mut self) {
// If we were cancelled, get out of here.
if !self.active { return; }
Expand Down
6 changes: 3 additions & 3 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Server<HttpListener> {

impl<
L: NetworkListener<Acceptor=A> + Send,
A: NetworkAcceptor<Stream=S> + Send,
A: NetworkAcceptor<Stream=S> + Send + 'static,
S: NetworkStream + Clone + Send> Server<L> {
/// Creates a new server that will handle `HttpStream`s.
pub fn with_listener(ip: IpAddr, port: Port, listener: L) -> Server<L> {
Expand All @@ -68,7 +68,7 @@ S: NetworkStream + Clone + Send> Server<L> {
}

/// 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);
let acceptor = try!(self.listener.listen((self.ip, self.port)));
let socket = try!(acceptor.socket_name());
Expand All @@ -85,7 +85,7 @@ S: NetworkStream + Clone + Send> Server<L> {
}

/// 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)
}

Expand Down

0 comments on commit f4a66b3

Please sign in to comment.