From 2debbdacb935cfe1eb7bb8d1f40a5063b339d90b Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 8 Apr 2019 17:10:00 -0400 Subject: Merge Worker and Isolate types (#2078) Reduces generics. --- cli/resources.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'cli/resources.rs') diff --git a/cli/resources.rs b/cli/resources.rs index 701d5a937..b1689c890 100644 --- a/cli/resources.rs +++ b/cli/resources.rs @@ -35,6 +35,7 @@ use std::sync::{Arc, Mutex}; use tokio; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::net::TcpStream; +use tokio::sync::mpsc; use tokio_process; pub type ResourceId = u32; // Sometimes referred to RID. @@ -309,7 +310,7 @@ pub fn add_worker(wc: WorkerChannels) -> Resource { pub fn post_message_to_worker( rid: ResourceId, buf: Buf, -) -> futures::sink::Send> { +) -> futures::sink::Send> { let mut table = RESOURCE_TABLE.lock().unwrap(); let maybe_repr = table.get_mut(&rid); match maybe_repr { @@ -334,9 +335,10 @@ impl Future for WorkerReceiver { let mut table = RESOURCE_TABLE.lock().unwrap(); let maybe_repr = table.get_mut(&self.rid); match maybe_repr { - Some(Repr::Worker(ref mut wc)) => wc.1.poll().map_err(|()| { - errors::new(errors::ErrorKind::Other, "recv msg error".to_string()) - }), + Some(Repr::Worker(ref mut wc)) => wc + .1 + .poll() + .map_err(|err| errors::new(errors::ErrorKind::Other, err.to_string())), _ => Err(bad_resource()), } } @@ -359,9 +361,10 @@ impl Stream for WorkerReceiverStream { let mut table = RESOURCE_TABLE.lock().unwrap(); let maybe_repr = table.get_mut(&self.rid); match maybe_repr { - Some(Repr::Worker(ref mut wc)) => wc.1.poll().map_err(|()| { - errors::new(errors::ErrorKind::Other, "recv msg error".to_string()) - }), + Some(Repr::Worker(ref mut wc)) => wc + .1 + .poll() + .map_err(|err| errors::new(errors::ErrorKind::Other, err.to_string())), _ => Err(bad_resource()), } } -- cgit v1.2.3