1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 12:37:49 +00:00

dd: Tidy includes

This commit is contained in:
Thomas Hurst 2023-05-03 16:30:53 +00:00
parent 52c93a4d10
commit 546631c8e7

View file

@ -33,9 +33,12 @@ use std::os::unix::fs::FileTypeExt;
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
use std::os::unix::fs::OpenOptionsExt; use std::os::unix::fs::OpenOptionsExt;
use std::path::Path; use std::path::Path;
use std::sync::mpsc; use std::sync::{
atomic::{AtomicBool, Ordering::Relaxed},
mpsc, Arc,
};
use std::thread; use std::thread;
use std::time; use std::time::{Duration, Instant};
use clap::{crate_version, Arg, Command}; use clap::{crate_version, Arg, Command};
use gcd::Gcd; use gcd::Gcd;
@ -65,14 +68,6 @@ struct Settings {
status: Option<StatusLevel>, status: Option<StatusLevel>,
} }
use std::thread::sleep;
use std::time::Duration;
use std::sync::{
atomic::{AtomicBool, Ordering::Relaxed},
Arc,
};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Alarm { pub struct Alarm {
interval: Duration, interval: Duration,
@ -84,9 +79,9 @@ impl Alarm {
let trigger = Arc::new(AtomicBool::default()); let trigger = Arc::new(AtomicBool::default());
let weak_trigger = Arc::downgrade(&trigger); let weak_trigger = Arc::downgrade(&trigger);
std::thread::spawn(move || { thread::spawn(move || {
while let Some(trigger) = weak_trigger.upgrade() { while let Some(trigger) = weak_trigger.upgrade() {
sleep(interval); thread::sleep(interval);
trigger.store(true, Relaxed); trigger.store(true, Relaxed);
} }
}); });
@ -646,7 +641,7 @@ fn dd_copy(mut i: Input, mut o: Output) -> std::io::Result<()> {
// of its report includes the throughput in bytes per second, // of its report includes the throughput in bytes per second,
// which requires knowing how long the process has been // which requires knowing how long the process has been
// running. // running.
let start = time::Instant::now(); let start = Instant::now();
// A good buffer size for reading. // A good buffer size for reading.
// //
@ -718,7 +713,7 @@ fn finalize<T>(
output: &mut Output, output: &mut Output,
rstat: ReadStat, rstat: ReadStat,
wstat: WriteStat, wstat: WriteStat,
start: time::Instant, start: Instant,
prog_tx: &mpsc::Sender<ProgUpdate>, prog_tx: &mpsc::Sender<ProgUpdate>,
output_thread: thread::JoinHandle<T>, output_thread: thread::JoinHandle<T>,
) -> std::io::Result<()> { ) -> std::io::Result<()> {