Skip to content

Commit b6ab444

Browse files
committed
Review poll timer logic for scheduled callbacks
1 parent d90d02b commit b6ab444

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/event_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl EventLoop {
110110
if let Some(timer) = guard_sched.peek() {
111111
let tick = Instant::now().duration_since(self.epoch).as_micros();
112112
if timer.when > tick {
113-
let dt = ((timer.when - tick) / 1000) as u64;
113+
let dt = (timer.when - tick) as u64;
114114
sched_time = Some(dt);
115115
}
116116
}
@@ -128,7 +128,7 @@ impl EventLoop {
128128
if sched_time.is_none() {
129129
self.idle.store(true, atomic::Ordering::Release);
130130
}
131-
let res = io.poll(&mut state.events, sched_time.map(Duration::from_millis));
131+
let res = io.poll(&mut state.events, sched_time.map(Duration::from_micros));
132132
if let Err(ref err) = res {
133133
if err.kind() == std::io::ErrorKind::Interrupted {
134134
// if we got an interrupt, we retry ready events (as we might need to process signals)

tests/handles/test_handles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def stop():
2727
loop.stop()
2828

2929
loop.call_later(0.001, cb, 2)
30-
loop.call_later(1.0, stop)
30+
loop.call_later(0.1, stop)
3131
loop.call_soon(cb, 1)
3232
loop.run_forever()
3333
assert calls == [1, 2]

0 commit comments

Comments
 (0)