17
17
*/
18
18
19
19
use either:: Either ;
20
- use pipes:: recv;
20
+ use pipes:: { recv, oneshot , ChanOne , PortOne , send_one , recv_one } ;
21
21
use cast:: copy_lifetime;
22
22
23
23
#[ doc = "The future type" ]
@@ -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 :: server :: waiting < A > ) ->
70
+ pub fn from_port < A : Send > ( port : PortOne < A > ) ->
71
71
Future < A > {
72
72
/*!
73
73
* Create a future from a port
@@ -82,7 +82,7 @@ pub fn from_port<A:Send>(port: future_pipe::server::waiting<A>) ->
82
82
port_ <-> * port;
83
83
let port = option:: unwrap ( move port_) ;
84
84
match recv ( move port) {
85
- future_pipe :: completed ( move data) => move data
85
+ oneshot :: send ( move data) => move data
86
86
}
87
87
}
88
88
}
@@ -107,12 +107,12 @@ pub fn spawn<A:Send>(blk: fn~() -> A) -> Future<A> {
107
107
* value of the future.
108
108
*/
109
109
110
- let ( chan, port) = future_pipe :: init ( ) ;
110
+ let ( chan, port) = oneshot :: init ( ) ;
111
111
112
112
let chan = ~mut Some ( move chan) ;
113
113
do task:: spawn |move blk, move chan| {
114
114
let chan = option:: swap_unwrap ( & mut * chan) ;
115
- future_pipe :: client :: completed ( move chan, blk ( ) ) ;
115
+ send_one ( move chan, blk ( ) ) ;
116
116
}
117
117
118
118
return from_port ( move port) ;
@@ -168,12 +168,6 @@ pub fn with<A,B>(future: &Future<A>, blk: fn((&A)) -> B) -> B {
168
168
blk ( get_ref ( future) )
169
169
}
170
170
171
- proto ! future_pipe (
172
- waiting: send<T : Send > {
173
- completed( T ) -> !
174
- }
175
- )
176
-
177
171
#[ allow( non_implicitly_copyable_typarams) ]
178
172
pub mod test {
179
173
#[ test]
@@ -184,8 +178,8 @@ pub mod test {
184
178
185
179
#[ test]
186
180
pub fn test_from_port ( ) {
187
- let ( ch, po) = future_pipe :: init ( ) ;
188
- future_pipe :: client :: completed ( move ch, ~"whale") ;
181
+ let ( ch, po) = oneshot :: init ( ) ;
182
+ send_one ( move ch, ~"whale") ;
189
183
let f = from_port ( move po) ;
190
184
assert get( & f) == ~"whale";
191
185
}
0 commit comments