mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Move util::time::duration_from_nanoseconds to its only caller
This commit is contained in:
parent
3041084176
commit
f8f00fac5b
2 changed files with 14 additions and 12 deletions
|
@ -10,8 +10,9 @@
|
||||||
use compositor_thread::{CompositorProxy, Msg};
|
use compositor_thread::{CompositorProxy, Msg};
|
||||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||||
use std::thread::{self, Builder};
|
use std::thread::{self, Builder};
|
||||||
|
use std::time::Duration;
|
||||||
|
use std::u32;
|
||||||
use time;
|
use time;
|
||||||
use util::time::duration_from_nanoseconds;
|
|
||||||
|
|
||||||
/// The amount of time in nanoseconds that we give to the painting thread to paint. When this
|
/// The amount of time in nanoseconds that we give to the painting thread to paint. When this
|
||||||
/// expires, we give up and composite anyway.
|
/// expires, we give up and composite anyway.
|
||||||
|
@ -92,3 +93,15 @@ impl DelayedCompositionTimer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn duration_from_nanoseconds(nanos: u64) -> Duration {
|
||||||
|
pub const NANOS_PER_SEC: u32 = 1_000_000_000;
|
||||||
|
|
||||||
|
// Get number of seconds.
|
||||||
|
let secs = nanos / NANOS_PER_SEC as u64;
|
||||||
|
|
||||||
|
// Get number of extra nanoseconds. This should always fit in a u32, but check anyway.
|
||||||
|
let subsec_nanos = nanos % NANOS_PER_SEC as u64;
|
||||||
|
assert!(subsec_nanos <= u32::MAX as u64);
|
||||||
|
|
||||||
|
Duration::new(secs, subsec_nanos as u32)
|
||||||
|
}
|
||||||
|
|
|
@ -18,14 +18,3 @@ pub fn duration_from_seconds(secs: f64) -> Duration {
|
||||||
|
|
||||||
Duration::new(whole_secs as u64, nanos as u32)
|
Duration::new(whole_secs as u64, nanos as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn duration_from_nanoseconds(nanos: u64) -> Duration {
|
|
||||||
// Get number of seconds.
|
|
||||||
let secs = nanos / NANOS_PER_SEC as u64;
|
|
||||||
|
|
||||||
// Get number of extra nanoseconds. This should always fit in a u32, but check anyway.
|
|
||||||
let subsec_nanos = nanos % NANOS_PER_SEC as u64;
|
|
||||||
assert!(subsec_nanos <= u32::MAX as u64);
|
|
||||||
|
|
||||||
Duration::new(secs, subsec_nanos as u32)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue