@@ -105,6 +105,7 @@ pub const ALARM_TRIGGER_TIMER: u8 = 1;
105
105
pub const ALARM_TRIGGER_SIGNAL : u8 = 2 ;
106
106
107
107
impl Alarm {
108
+ /// use to construct alarm timer with duration
108
109
pub fn with_interval ( interval : Duration ) -> Self {
109
110
let trigger = Arc :: new ( AtomicU8 :: default ( ) ) ;
110
111
@@ -119,6 +120,11 @@ impl Alarm {
119
120
Self { interval, trigger }
120
121
}
121
122
123
+ /// Returns a closure that allows to manually trigger the alarm
124
+ ///
125
+ /// This is useful for cases where more than one alarm even source exists
126
+ /// In case of `dd` there is the SIGUSR1/SIGINFO case where we want to
127
+ /// trigger an manual progress report.
122
128
pub fn manual_trigger_fn ( & self ) -> Box < dyn Send + Sync + Fn ( ) > {
123
129
let weak_trigger = Arc :: downgrade ( & self . trigger ) ;
124
130
Box :: new ( move || {
@@ -128,10 +134,17 @@ impl Alarm {
128
134
} )
129
135
}
130
136
137
+ /// Use this function to poll for any pending alarm event
138
+ ///
139
+ /// Returns `ALARM_TRIGGER_NONE` for no pending event.
140
+ /// Returns `ALARM_TRIGGER_TIMER` if the event was triggered by timer
141
+ /// Returns `ALARM_TRIGGER_SIGNAL` if the event was triggered manually
142
+ /// by the closure returned from `manual_trigger_fn`
131
143
pub fn get_trigger ( & self ) -> u8 {
132
144
self . trigger . swap ( ALARM_TRIGGER_NONE , Relaxed )
133
145
}
134
146
147
+ // Getter function for the configured interval duration
135
148
pub fn get_interval ( & self ) -> Duration {
136
149
self . interval
137
150
}
@@ -959,6 +972,8 @@ impl<'a> BlockWriter<'a> {
959
972
}
960
973
}
961
974
975
+ /// depending on the command line arguments, this function
976
+ /// informs the OS to flush/discard the caches for input and/or output file.
962
977
fn flush_caches_full_length ( i : & Input , o : & Output ) -> std:: io:: Result < ( ) > {
963
978
// TODO Better error handling for overflowing `len`.
964
979
if i. settings . iflags . nocache {
0 commit comments