mirror of
https://github.com/servo/servo.git
synced 2025-08-18 03:45:33 +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
|
@ -11,8 +11,9 @@ use profile_traits::mem::{ProfilerChan, ProfilerMsg, ReportKind, Reporter, Repor
|
|||
use std::borrow::ToOwned;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
use std::thread::sleep_ms;
|
||||
use std::thread;
|
||||
use util::task::spawn_named;
|
||||
use util::time::duration_from_seconds;
|
||||
|
||||
pub struct Profiler {
|
||||
/// The port through which messages are received.
|
||||
|
@ -31,11 +32,10 @@ impl Profiler {
|
|||
|
||||
// Create the timer thread if a period was provided.
|
||||
if let Some(period) = period {
|
||||
let period_ms = (period * 1000.) as u32;
|
||||
let chan = chan.clone();
|
||||
spawn_named("Memory profiler timer".to_owned(), move || {
|
||||
loop {
|
||||
sleep_ms(period_ms);
|
||||
thread::sleep(duration_from_seconds(period));
|
||||
if chan.send(ProfilerMsg::Print).is_err() {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -12,10 +12,11 @@ use profile_traits::time::{TimerMetadataReflowType, TimerMetadataFrameType};
|
|||
use std::borrow::ToOwned;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::BTreeMap;
|
||||
use std::f64;
|
||||
use std::thread::sleep_ms;
|
||||
use std::time::Duration;
|
||||
use std::{thread, f64};
|
||||
use std_time::precise_time_ns;
|
||||
use util::task::spawn_named;
|
||||
use util::time::duration_from_seconds;
|
||||
|
||||
pub trait Formattable {
|
||||
fn format(&self) -> String;
|
||||
|
@ -123,11 +124,10 @@ impl Profiler {
|
|||
let (chan, port) = ipc::channel().unwrap();
|
||||
match period {
|
||||
Some(period) => {
|
||||
let period = (period * 1000.) as u32;
|
||||
let chan = chan.clone();
|
||||
spawn_named("Time profiler timer".to_owned(), move || {
|
||||
loop {
|
||||
sleep_ms(period);
|
||||
thread::sleep(duration_from_seconds(period));
|
||||
if chan.send(ProfilerMsg::Print).is_err() {
|
||||
break;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ impl Profiler {
|
|||
loop {
|
||||
for _ in 0..loop_count {
|
||||
match run_ap_thread() {
|
||||
true => sleep_ms(SLEEP_MS),
|
||||
true => thread::sleep(Duration::from_millis(SLEEP_MS as u64)),
|
||||
false => return,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue