Skip to content

Commit 60c2981

Browse files
committed
---
yaml --- r: 34891 b: refs/heads/master c: 50f9925 h: refs/heads/master i: 34889: 2059648 34887: db96e62 v: v3
1 parent b72f118 commit 60c2981

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 759e1c165f474314bb113d0b72e8ef85fc3864d7
2+
refs/heads/master: 50f9925fabbc738f7be0df8148c99fae3e975bb1
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024

trunk/src/libcore/future.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn from_value<A>(val: A) -> Future<A> {
6767
Future {state: Forced(~(move val))}
6868
}
6969

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>) ->
7171
Future<A> {
7272
/*!
7373
* Create a future from a port
@@ -107,9 +107,15 @@ pub fn spawn<A:Send>(blk: fn~() -> A) -> Future<A> {
107107
* value of the future.
108108
*/
109109

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);
113119
}
114120

115121
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 {
163169
}
164170

165171
proto! future_pipe (
166-
waiting:recv<T:Send> {
172+
waiting:send<T:Send> {
167173
completed(T) -> !
168174
}
169175
)
@@ -178,8 +184,8 @@ pub mod test {
178184

179185
#[test]
180186
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");
183189
let f = from_port(move po);
184190
assert get(&f) == ~"whale";
185191
}

0 commit comments

Comments
 (0)