@@ -126,15 +126,17 @@ mod test {
126
126
127
127
use core:: iter;
128
128
use core:: libc;
129
- use core:: oldcomm;
130
129
use core:: ptr;
131
130
use core:: task;
131
+ use core:: cast:: transmute;
132
+ use core:: libc:: c_void;
133
+ use core:: pipes:: { stream, SharedChan , Chan } ;
132
134
133
135
extern fn simple_timer_close_cb ( timer_ptr : * ll:: uv_timer_t ) unsafe {
134
136
let exit_ch_ptr = ll:: get_data_for_uv_handle (
135
- timer_ptr as * libc:: c_void ) as * oldcomm :: Chan < bool > ;
136
- let exit_ch = * exit_ch_ptr;
137
- oldcomm :: send ( exit_ch , true ) ;
137
+ timer_ptr as * libc:: c_void ) ;
138
+ let exit_ch = transmute :: < * c_void , ~ Chan < bool > > ( exit_ch_ptr) ;
139
+ exit_ch . send ( true ) ;
138
140
log ( debug, fmt ! ( "EXIT_CH_PTR simple_timer_close_cb exit_ch_ptr: %?" ,
139
141
exit_ch_ptr) ) ;
140
142
}
@@ -153,9 +155,8 @@ mod test {
153
155
}
154
156
155
157
fn impl_uv_hl_simple_timer( iotask : & IoTask ) unsafe {
156
- let exit_po = oldcomm:: Port :: < bool > ( ) ;
157
- let exit_ch = oldcomm:: Chan ( & exit_po) ;
158
- let exit_ch_ptr = ptr:: addr_of ( & exit_ch) ;
158
+ let ( exit_po, exit_ch) = stream :: < bool > ( ) ;
159
+ let exit_ch_ptr: * libc:: c_void = transmute ( ~exit_ch) ;
159
160
log ( debug, fmt ! ( "EXIT_CH_PTR newly created exit_ch_ptr: %?" ,
160
161
exit_ch_ptr) ) ;
161
162
let timer_handle = ll:: timer_t ( ) ;
@@ -166,7 +167,7 @@ mod test {
166
167
if(init_status == 0i32) {
167
168
ll::set_data_for_uv_handle(
168
169
timer_ptr as *libc::c_void,
169
- exit_ch_ptr as *libc::c_void );
170
+ exit_ch_ptr);
170
171
let start_status = ll::timer_start(timer_ptr, simple_timer_cb,
171
172
1u, 0u);
172
173
if(start_status == 0i32) {
@@ -179,41 +180,41 @@ mod test {
179
180
fail ~"failure on ll:: timer_init ( ) ";
180
181
}
181
182
} ;
182
- oldcomm :: recv ( exit_po ) ;
183
+ exit_po . recv ( ) ;
183
184
log( debug, ~"global_loop timer test: msg recv on exit_po, done..");
184
185
}
185
186
186
187
#[test]
187
188
fn test_gl_uv_global_loop_high_level_global_timer() unsafe {
188
189
let hl_loop = &get_gl();
189
- let exit_po = oldcomm::Port::<()>();
190
- let exit_ch = oldcomm::Chan(&exit_po);
190
+ let (exit_po, exit_ch) = stream::<()>();
191
191
task::spawn_sched(task::ManualThreads(1u), || {
192
192
let hl_loop = &get_gl();
193
193
impl_uv_hl_simple_timer(hl_loop);
194
- oldcomm:: send(exit_ch, ());
194
+ exit_ch. send(());
195
195
});
196
196
impl_uv_hl_simple_timer(hl_loop);
197
- oldcomm:: recv(exit_po );
197
+ exit_po. recv();
198
198
}
199
199
200
200
// keeping this test ignored until some kind of stress-test-harness
201
201
// is set up for the build bots
202
202
#[test]
203
203
#[ignore]
204
204
fn test_stress_gl_uv_global_loop_high_level_global_timer() unsafe {
205
- let exit_po = oldcomm::Port ::<()>();
206
- let exit_ch = oldcomm::Chan(&exit_po );
205
+ let ( exit_po, exit_ch) = stream ::<()>();
206
+ let exit_ch = SharedChan(exit_ch );
207
207
let cycles = 5000u;
208
208
for iter::repeat(cycles) {
209
+ let exit_ch_clone = exit_ch.clone();
209
210
task::spawn_sched(task::ManualThreads(1u), || {
210
211
let hl_loop = &get_gl();
211
212
impl_uv_hl_simple_timer(hl_loop);
212
- oldcomm:: send(exit_ch, ());
213
+ exit_ch_clone. send(());
213
214
});
214
215
};
215
216
for iter::repeat(cycles) {
216
- oldcomm:: recv(exit_po );
217
+ exit_po. recv();
217
218
};
218
219
log(debug, ~" test_stress_gl_uv_global_loop_high_level_global_timer"+
219
220
~" exiting sucessfully!") ;
0 commit comments