Remove the 'callback_ms' function from EventLoop
This is a peculiar function to require event loops to implement, and it's only used in one spot during tests right now. Instead, a possibly more robust apis for timers should be used rather than requiring all event loops to implement a curious-looking function.
This commit is contained in:
parent
3b30377e14
commit
3ee5ef12fb
3 changed files with 3 additions and 20 deletions
|
@ -28,7 +28,6 @@ pub trait EventLoop {
|
||||||
fn run(&mut self);
|
fn run(&mut self);
|
||||||
fn callback(&mut self, ~fn());
|
fn callback(&mut self, ~fn());
|
||||||
fn pausible_idle_callback(&mut self) -> ~PausibleIdleCallback;
|
fn pausible_idle_callback(&mut self) -> ~PausibleIdleCallback;
|
||||||
fn callback_ms(&mut self, ms: u64, ~fn());
|
|
||||||
fn remote_callback(&mut self, ~fn()) -> ~RemoteCallback;
|
fn remote_callback(&mut self, ~fn()) -> ~RemoteCallback;
|
||||||
|
|
||||||
/// The asynchronous I/O services. Not all event loops may provide one
|
/// The asynchronous I/O services. Not all event loops may provide one
|
||||||
|
|
|
@ -1147,22 +1147,15 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_io_callback() {
|
fn test_io_callback() {
|
||||||
|
use rt::io::timer;
|
||||||
|
|
||||||
// This is a regression test that when there are no schedulable tasks
|
// This is a regression test that when there are no schedulable tasks
|
||||||
// in the work queue, but we are performing I/O, that once we do put
|
// in the work queue, but we are performing I/O, that once we do put
|
||||||
// something in the work queue again the scheduler picks it up and doesn't
|
// something in the work queue again the scheduler picks it up and doesn't
|
||||||
// exit before emptying the work queue
|
// exit before emptying the work queue
|
||||||
do run_in_newsched_task {
|
do run_in_newsched_task {
|
||||||
do spawntask {
|
do spawntask {
|
||||||
let sched: ~Scheduler = Local::take();
|
timer::sleep(10);
|
||||||
do sched.deschedule_running_task_and_then |sched, task| {
|
|
||||||
let task = Cell::new(task);
|
|
||||||
do sched.event_loop.callback_ms(10) {
|
|
||||||
rtdebug!("in callback");
|
|
||||||
let mut sched: ~Scheduler = Local::take();
|
|
||||||
sched.enqueue_blocked_task(task.take());
|
|
||||||
Local::put(sched);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,15 +222,6 @@ impl EventLoop for UvEventLoop {
|
||||||
} as ~PausibleIdleCallback
|
} as ~PausibleIdleCallback
|
||||||
}
|
}
|
||||||
|
|
||||||
fn callback_ms(&mut self, ms: u64, f: ~fn()) {
|
|
||||||
let mut timer = TimerWatcher::new(self.uvio.uv_loop());
|
|
||||||
do timer.start(ms, 0) |timer, status| {
|
|
||||||
assert!(status.is_none());
|
|
||||||
timer.close(||());
|
|
||||||
f();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn remote_callback(&mut self, f: ~fn()) -> ~RemoteCallback {
|
fn remote_callback(&mut self, f: ~fn()) -> ~RemoteCallback {
|
||||||
~UvRemoteCallback::new(self.uvio.uv_loop(), f) as ~RemoteCallback
|
~UvRemoteCallback::new(self.uvio.uv_loop(), f) as ~RemoteCallback
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue