Skip to content

Commit 27129c6

Browse files
olsonjefferybrson
authored andcommitted
core/std: finish making futures sendable + test.. still issues
1 parent 6bdda1e commit 27129c6

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/libcore/future.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct Future<A> {
3737
}
3838

3939
priv enum FutureState<A> {
40-
Pending(fn@() -> A),
40+
Pending(fn~() -> A),
4141
Evaluating,
4242
Forced(A)
4343
}
@@ -93,7 +93,7 @@ fn from_port<A:Send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
9393
}
9494
}
9595

96-
fn from_fn<A>(+f: @fn() -> A) -> Future<A> {
96+
fn from_fn<A>(+f: ~fn() -> A) -> Future<A> {
9797
/*!
9898
* Create a future from a function.
9999
*
@@ -239,4 +239,14 @@ mod test {
239239
let f = spawn(|| fail);
240240
let _x: ~str = get(&f);
241241
}
242-
}
242+
243+
#[test]
244+
fn test_sendable_future() {
245+
let expected = ~"schlorf";
246+
let f = do spawn |copy expected| { expected };
247+
do task::spawn {
248+
let actual = get(&f);
249+
assert actual == expected;
250+
}
251+
}
252+
}

src/libcore/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ fn test_spawn_linked_sup_fail_down() { // parent fails; child fails
17541754
opts.supervised = true;
17551755
move opts
17561756
};
1757-
1757+
17581758
let b0 = task();
17591759
let b1 = TaskBuilder({
17601760
opts: move opts,

src/rustdoc/markdown_writer.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,14 @@ fn future_writer_factory(
285285
}
286286
287287
fn future_writer() -> (writer, future::Future<~str>) {
288-
let port = comm::Port();
289-
let chan = comm::Chan(port);
288+
let (chan, port) = pipes::stream();
290289
let writer = fn~(+instr: writeinstr) {
291-
comm::send(chan, copy instr);
290+
chan.send(copy instr);
292291
};
293292
let future = do future::from_fn {
294293
let mut res = ~"";
295294
loop {
296-
match comm::recv(port) {
295+
match port.recv() {
297296
write(s) => res += s,
298297
done => break
299298
}

0 commit comments

Comments
 (0)