Skip to content

Commit 01a6524

Browse files
committed
Stop using spawn_conversation in chan_from_global_ptr
1 parent c35a858 commit 01a6524

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/libcore/private.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,29 @@ pub unsafe fn chan_from_global_ptr<T: Owned>(
7070
log(debug,~"is probably zero...");
7171
// There's no global channel. We must make it
7272
73-
let (setup_po, setup_ch) = do task_fn().spawn_conversation
74-
|move f, setup_po, setup_ch| {
73+
let (setup1_po, setup1_ch) = pipes::stream();
74+
let (setup2_po, setup2_ch) = pipes::stream();
75+
76+
// XXX: Ugly type inference hints
77+
let setup1_po: pipes::Port<comm::Chan<T>> = setup1_po;
78+
let setup2_po: pipes::Port<Msg> = setup2_po;
79+
80+
do task_fn().spawn |move f, move setup1_ch, move setup2_po| {
7581
let po = comm::Port::<T>();
7682
let ch = comm::Chan(&po);
77-
comm::send(setup_ch, ch);
83+
setup1_ch.send(ch);
7884
7985
// Wait to hear if we are the official instance of
8086
// this global task
81-
match comm::recv::<Msg>(setup_po) {
87+
match setup2_po.recv() {
8288
Proceed => f(move po),
8389
Abort => ()
8490
}
8591
};
8692
8793
log(debug,~"before setup recv..");
8894
// This is the proposed global channel
89-
let ch = comm::recv(setup_po);
95+
let ch = setup1_po.recv();
9096
// 0 is our sentinal value. It is not a valid channel
9197
assert *ch != 0;
9298
@@ -99,11 +105,11 @@ pub unsafe fn chan_from_global_ptr<T: Owned>(
99105

100106
if swapped {
101107
// Success!
102-
comm::send(setup_ch, Proceed);
108+
setup2_ch.send(Proceed);
103109
ch
104110
} else {
105111
// Somebody else got in before we did
106-
comm::send(setup_ch, Abort);
112+
setup2_ch.send(Abort);
107113
cast::reinterpret_cast(&*global)
108114
}
109115
} else {

0 commit comments

Comments
 (0)