fix(server): Use thread::spawn instead of thread::scoped.

This commit is contained in:
Jonathan Reem
2015-04-15 12:32:16 -07:00
parent eab8fcd081
commit e864956734
3 changed files with 28 additions and 30 deletions

View File

@@ -3,7 +3,7 @@ use std::io::{BufWriter, Write};
use std::marker::PhantomData;
use std::net::{SocketAddr, ToSocketAddrs};
use std::path::Path;
use std::thread::{self, JoinGuard};
use std::thread::{self, JoinHandle};
use num_cpus;
@@ -104,7 +104,7 @@ S: NetworkStream + Clone + Send> Server<'a, H, L> {
let pool = ListenerPool::new(listener.clone());
let work = move |mut stream| handle_connection(&mut stream, &handler);
let guard = thread::scoped(move || pool.accept(work, threads));
let guard = thread::spawn(move || pool.accept(work, threads));
Ok(Listening {
_guard: guard,
@@ -175,7 +175,10 @@ where S: NetworkStream + Clone, H: Handler {
/// A listening server, which can later be closed.
pub struct Listening {
_guard: JoinGuard<'static, ()>,
#[cfg(feature = "nightly")]
_guard: JoinHandle<()>,
#[cfg(not(feature = "nightly"))]
_guard: JoinHandle,
/// The socket addresses that the server is bound to.
pub socket: SocketAddr,
}