diff --git a/src/libcore/future.rs b/src/libcore/future.rs
index bc35dafde352..8d4540605347 100644
--- a/src/libcore/future.rs
+++ b/src/libcore/future.rs
@@ -67,7 +67,7 @@ pub fn from_value(val: A) -> Future {
Future {state: Forced(~(move val))}
}
-pub fn from_port(port: future_pipe::client::waiting) ->
+pub fn from_port(port: future_pipe::server::waiting) ->
Future {
/*!
* Create a future from a port
@@ -107,9 +107,15 @@ pub fn spawn(blk: fn~() -> A) -> Future {
* value of the future.
*/
- from_port(pipes::spawn_service_recv(future_pipe::init, |move blk, ch| {
- future_pipe::server::completed(move ch, blk());
- }))
+ let (chan, port) = future_pipe::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());
+ }
+
+ return from_port(move port);
}
pub fn get_ref(future: &r/Future) -> &r/A {
@@ -163,7 +169,7 @@ pub fn with(future: &Future, blk: fn((&A)) -> B) -> B {
}
proto! future_pipe (
- waiting:recv {
+ waiting:send {
completed(T) -> !
}
)
@@ -178,8 +184,8 @@ pub mod test {
#[test]
pub fn test_from_port() {
- let (po, ch) = future_pipe::init();
- future_pipe::server::completed(move ch, ~"whale");
+ let (ch, po) = future_pipe::init();
+ future_pipe::client::completed(move ch, ~"whale");
let f = from_port(move po);
assert get(&f) == ~"whale";
}