mirror of
https://github.com/uutils/coreutils
synced 2025-01-07 10:49:09 +00:00
dd: Add documentation to Alarm struct
This commit is contained in:
parent
546631c8e7
commit
01a8623d21
1 changed files with 14 additions and 0 deletions
|
@ -68,6 +68,15 @@ struct Settings {
|
||||||
status: Option<StatusLevel>,
|
status: Option<StatusLevel>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A timer which triggers on a given interval
|
||||||
|
///
|
||||||
|
/// After being constructed with [`Alarm::with_interval`], [`Alarm::is_triggered`]
|
||||||
|
/// will return true once per the given [`Duration`].
|
||||||
|
///
|
||||||
|
/// Can be cloned, but the trigger status is shared across all instances so only
|
||||||
|
/// the first caller each interval will yield true.
|
||||||
|
///
|
||||||
|
/// When all instances are dropped the background thread will exit on the next interval.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Alarm {
|
pub struct Alarm {
|
||||||
interval: Duration,
|
interval: Duration,
|
||||||
|
@ -671,6 +680,11 @@ fn dd_copy(mut i: Input, mut o: Output) -> std::io::Result<()> {
|
||||||
// Create a common buffer with a capacity of the block size.
|
// Create a common buffer with a capacity of the block size.
|
||||||
// This is the max size needed.
|
// This is the max size needed.
|
||||||
let mut buf = vec![BUF_INIT_BYTE; bsize];
|
let mut buf = vec![BUF_INIT_BYTE; bsize];
|
||||||
|
|
||||||
|
// Spawn a timer thread to provide a scheduled signal indicating when we
|
||||||
|
// should send an update of our progress to the reporting thread.
|
||||||
|
//
|
||||||
|
// This avoids the need to query the OS monotonic clock for every block.
|
||||||
let alarm = Alarm::with_interval(Duration::from_secs(1));
|
let alarm = Alarm::with_interval(Duration::from_secs(1));
|
||||||
|
|
||||||
// The main read/write loop.
|
// The main read/write loop.
|
||||||
|
|
Loading…
Reference in a new issue