mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Use thread::sleep instead of deprecated sleep_ms
Similarly, change one instance of `thread::park_timeout_ms`. Fixes #8694
This commit is contained in:
parent
b737e4e0fa
commit
3659218c59
10 changed files with 65 additions and 25 deletions
|
@ -6,13 +6,15 @@
|
|||
|
||||
use compositor_task::{CompositorProxy, Msg};
|
||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
use std::thread::{Builder, sleep_ms};
|
||||
use std::thread::{self, Builder};
|
||||
use std::u32;
|
||||
use time;
|
||||
use util::time::duration_from_nanoseconds;
|
||||
|
||||
/// The amount of time in nanoseconds that we give to the painting thread to paint new tiles upon
|
||||
/// processing a scroll event that caused new tiles to be revealed. When this expires, we give up
|
||||
/// and composite anyway (showing a "checkerboard") to avoid dropping the frame.
|
||||
static TIMEOUT: i64 = 12_000_000;
|
||||
static TIMEOUT: u64 = 12_000_000;
|
||||
|
||||
pub struct ScrollingTimerProxy {
|
||||
sender: Sender<ToScrollingTimerMsg>,
|
||||
|
@ -55,9 +57,9 @@ impl ScrollingTimerProxy {
|
|||
impl ScrollingTimer {
|
||||
pub fn run(&mut self) {
|
||||
while let Ok(ToScrollingTimerMsg::ScrollEventProcessedMsg(timestamp)) = self.receiver.recv() {
|
||||
let target = timestamp as i64 + TIMEOUT;
|
||||
let delta_ns = target - (time::precise_time_ns() as i64);
|
||||
sleep_ms((delta_ns / 1000000) as u32);
|
||||
let target = timestamp + TIMEOUT;
|
||||
let delta_ns = target - time::precise_time_ns();
|
||||
thread::sleep(duration_from_nanoseconds(delta_ns));
|
||||
self.compositor_proxy.send(Msg::ScrollTimeout(timestamp));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ use std::sync::Arc;
|
|||
use std::sync::atomic::{self, AtomicBool};
|
||||
use std::sync::mpsc::{channel, Receiver, Select};
|
||||
use std::thread::{self, spawn, Thread};
|
||||
use std::time::Duration;
|
||||
use util::task::spawn_named;
|
||||
|
||||
/// A quick hack to work around the removal of [`std::old_io::timer::Timer`](
|
||||
|
@ -37,7 +38,7 @@ impl CancelableOneshotTimer {
|
|||
let mut park_time = duration;
|
||||
|
||||
loop {
|
||||
thread::park_timeout_ms(park_time.get() as u32);
|
||||
thread::park_timeout(Duration::from_millis(park_time.get()));
|
||||
|
||||
if canceled_clone.load(atomic::Ordering::Relaxed) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue