From 84c85496227e1b31f763dfd7e9a82c9b5da52407 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 22 Oct 2012 16:35:40 -0700 Subject: [PATCH] core: Replace future_pipe with pipe::oneshot --- src/libcore/future.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/libcore/future.rs b/src/libcore/future.rs index 8d454060534..503e915cf87 100644 --- a/src/libcore/future.rs +++ b/src/libcore/future.rs @@ -17,7 +17,7 @@ */ use either::Either; -use pipes::recv; +use pipes::{recv, oneshot, ChanOne, PortOne, send_one, recv_one}; use cast::copy_lifetime; #[doc = "The future type"] @@ -67,7 +67,7 @@ pub fn from_value(val: A) -> Future { Future {state: Forced(~(move val))} } -pub fn from_port(port: future_pipe::server::waiting) -> +pub fn from_port(port: PortOne) -> Future { /*! * Create a future from a port @@ -82,7 +82,7 @@ pub fn from_port(port: future_pipe::server::waiting) -> port_ <-> *port; let port = option::unwrap(move port_); match recv(move port) { - future_pipe::completed(move data) => move data + oneshot::send(move data) => move data } } } @@ -107,12 +107,12 @@ pub fn spawn(blk: fn~() -> A) -> Future { * value of the future. */ - let (chan, port) = future_pipe::init(); + let (chan, port) = oneshot::init(); let chan = ~mut Some(move chan); do task::spawn |move blk, move chan| { let chan = option::swap_unwrap(&mut *chan); - future_pipe::client::completed(move chan, blk()); + send_one(move chan, blk()); } return from_port(move port); @@ -168,12 +168,6 @@ pub fn with(future: &Future, blk: fn((&A)) -> B) -> B { blk(get_ref(future)) } -proto! future_pipe ( - waiting:send { - completed(T) -> ! - } -) - #[allow(non_implicitly_copyable_typarams)] pub mod test { #[test] @@ -184,8 +178,8 @@ pub fn test_from_value() { #[test] pub fn test_from_port() { - let (ch, po) = future_pipe::init(); - future_pipe::client::completed(move ch, ~"whale"); + let (ch, po) = oneshot::init(); + send_one(move ch, ~"whale"); let f = from_port(move po); assert get(&f) == ~"whale"; }