Skip to content

Commit 19aa88c

Browse files
committed
Stop using oldcomm in uv_global_loop tests
1 parent bc0c5bb commit 19aa88c

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/libstd/uv_global_loop.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,17 @@ mod test {
126126

127127
use core::iter;
128128
use core::libc;
129-
use core::oldcomm;
130129
use core::ptr;
131130
use core::task;
131+
use core::cast::transmute;
132+
use core::libc::c_void;
133+
use core::pipes::{stream, SharedChan, Chan};
132134

133135
extern fn simple_timer_close_cb(timer_ptr: *ll::uv_timer_t) unsafe {
134136
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);
138140
log(debug, fmt!("EXIT_CH_PTR simple_timer_close_cb exit_ch_ptr: %?",
139141
exit_ch_ptr));
140142
}
@@ -153,9 +155,8 @@ mod test {
153155
}
154156

155157
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);
159160
log(debug, fmt!("EXIT_CH_PTR newly created exit_ch_ptr: %?",
160161
exit_ch_ptr));
161162
let timer_handle = ll::timer_t();
@@ -166,7 +167,7 @@ mod test {
166167
if(init_status == 0i32) {
167168
ll::set_data_for_uv_handle(
168169
timer_ptr as *libc::c_void,
169-
exit_ch_ptr as *libc::c_void);
170+
exit_ch_ptr);
170171
let start_status = ll::timer_start(timer_ptr, simple_timer_cb,
171172
1u, 0u);
172173
if(start_status == 0i32) {
@@ -179,41 +180,41 @@ mod test {
179180
fail ~"failure on ll::timer_init()";
180181
}
181182
};
182-
oldcomm::recv(exit_po);
183+
exit_po.recv();
183184
log(debug, ~"global_loop timer test: msg recv on exit_po, done..");
184185
}
185186
186187
#[test]
187188
fn test_gl_uv_global_loop_high_level_global_timer() unsafe {
188189
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::<()>();
191191
task::spawn_sched(task::ManualThreads(1u), || {
192192
let hl_loop = &get_gl();
193193
impl_uv_hl_simple_timer(hl_loop);
194-
oldcomm::send(exit_ch, ());
194+
exit_ch.send(());
195195
});
196196
impl_uv_hl_simple_timer(hl_loop);
197-
oldcomm::recv(exit_po);
197+
exit_po.recv();
198198
}
199199
200200
// keeping this test ignored until some kind of stress-test-harness
201201
// is set up for the build bots
202202
#[test]
203203
#[ignore]
204204
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);
207207
let cycles = 5000u;
208208
for iter::repeat(cycles) {
209+
let exit_ch_clone = exit_ch.clone();
209210
task::spawn_sched(task::ManualThreads(1u), || {
210211
let hl_loop = &get_gl();
211212
impl_uv_hl_simple_timer(hl_loop);
212-
oldcomm::send(exit_ch, ());
213+
exit_ch_clone.send(());
213214
});
214215
};
215216
for iter::repeat(cycles) {
216-
oldcomm::recv(exit_po);
217+
exit_po.recv();
217218
};
218219
log(debug, ~"test_stress_gl_uv_global_loop_high_level_global_timer"+
219220
~" exiting sucessfully!");

0 commit comments

Comments
 (0)