@@ -70,23 +70,29 @@ pub unsafe fn chan_from_global_ptr<T: Owned>(
70
70
log ( debug, ~"is probably zero...");
71
71
// There's no global channel. We must make it
72
72
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| {
75
81
let po = comm::Port::<T>();
76
82
let ch = comm::Chan(&po);
77
- comm:: send(setup_ch, ch);
83
+ setup1_ch. send(ch);
78
84
79
85
// Wait to hear if we are the official instance of
80
86
// this global task
81
- match comm:: recv::<Msg>(setup_po ) {
87
+ match setup2_po. recv( ) {
82
88
Proceed => f(move po),
83
89
Abort => ()
84
90
}
85
91
};
86
92
87
93
log(debug,~" before setup recv..");
88
94
// This is the proposed global channel
89
- let ch = comm:: recv(setup_po );
95
+ let ch = setup1_po. recv();
90
96
// 0 is our sentinal value. It is not a valid channel
91
97
assert *ch != 0;
92
98
@@ -99,11 +105,11 @@ pub unsafe fn chan_from_global_ptr<T: Owned>(
99
105
100
106
if swapped {
101
107
// Success!
102
- comm :: send ( setup_ch , Proceed ) ;
108
+ setup2_ch . send ( Proceed ) ;
103
109
ch
104
110
} else {
105
111
// Somebody else got in before we did
106
- comm :: send ( setup_ch , Abort ) ;
112
+ setup2_ch . send ( Abort ) ;
107
113
cast:: reinterpret_cast ( & * global)
108
114
}
109
115
} else {
0 commit comments