@@ -67,7 +67,7 @@ pub fn from_value<A>(val: A) -> Future<A> {
67
67
Future { state : Forced ( ~( move val) ) }
68
68
}
69
69
70
- pub fn from_port < A : Send > ( port : future_pipe:: client :: waiting < A > ) ->
70
+ pub fn from_port < A : Send > ( port : future_pipe:: server :: waiting < A > ) ->
71
71
Future < A > {
72
72
/*!
73
73
* Create a future from a port
@@ -107,9 +107,15 @@ pub fn spawn<A:Send>(blk: fn~() -> A) -> Future<A> {
107
107
* value of the future.
108
108
*/
109
109
110
- from_port ( pipes:: spawn_service_recv ( future_pipe:: init, |move blk, ch| {
111
- future_pipe:: server:: completed ( move ch, blk ( ) ) ;
112
- } ) )
110
+ let ( chan, port) = future_pipe:: init ( ) ;
111
+
112
+ let chan = ~mut Some ( move chan) ;
113
+ do task:: spawn |move blk, move chan| {
114
+ let chan = option:: swap_unwrap ( & mut * chan) ;
115
+ future_pipe:: client:: completed ( move chan, blk ( ) ) ;
116
+ }
117
+
118
+ return from_port ( move port) ;
113
119
}
114
120
115
121
pub fn get_ref < A > ( future : & r/Future < A > ) -> & r /A {
@@ -163,7 +169,7 @@ pub fn with<A,B>(future: &Future<A>, blk: fn((&A)) -> B) -> B {
163
169
}
164
170
165
171
proto ! future_pipe (
166
- waiting: recv <T : Send > {
172
+ waiting: send <T : Send > {
167
173
completed( T ) -> !
168
174
}
169
175
)
@@ -178,8 +184,8 @@ pub mod test {
178
184
179
185
#[ test]
180
186
pub fn test_from_port ( ) {
181
- let ( po , ch ) = future_pipe:: init ( ) ;
182
- future_pipe:: server :: completed ( move ch, ~"whale") ;
187
+ let ( ch , po ) = future_pipe:: init ( ) ;
188
+ future_pipe:: client :: completed ( move ch, ~"whale") ;
183
189
let f = from_port ( move po) ;
184
190
assert get( & f) == ~"whale";
185
191
}
0 commit comments