This commit is contained in:
sylvestre
2023-06-20 02:39:37 +00:00
parent 2c94811274
commit d7a5f5ef80
16 changed files with 132 additions and 14 deletions
@@ -1,5 +1,6 @@
(function() {var implementors = {
"uu_cp":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/clone/trait.Clone.html\" title=\"trait core::clone::Clone\">Clone</a> for <a class=\"enum\" href=\"uu_cp/enum.ClobberMode.html\" title=\"enum uu_cp::ClobberMode\">ClobberMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/clone/trait.Clone.html\" title=\"trait core::clone::Clone\">Clone</a> for <a class=\"enum\" href=\"uu_cp/enum.SparseMode.html\" title=\"enum uu_cp::SparseMode\">SparseMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/clone/trait.Clone.html\" title=\"trait core::clone::Clone\">Clone</a> for <a class=\"enum\" href=\"uu_cp/enum.ReflinkMode.html\" title=\"enum uu_cp::ReflinkMode\">ReflinkMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/clone/trait.Clone.html\" title=\"trait core::clone::Clone\">Clone</a> for <a class=\"enum\" href=\"uu_cp/enum.OverwriteMode.html\" title=\"enum uu_cp::OverwriteMode\">OverwriteMode</a>"]],
"uu_dd":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/clone/trait.Clone.html\" title=\"trait core::clone::Clone\">Clone</a> for <a class=\"struct\" href=\"uu_dd/struct.Alarm.html\" title=\"struct uu_dd::Alarm\">Alarm</a>"]],
"uu_factor":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/clone/trait.Clone.html\" title=\"trait core::clone::Clone\">Clone</a> for <a class=\"struct\" href=\"uu_factor/struct.Factors.html\" title=\"struct uu_factor::Factors\">Factors</a>"]],
"uu_install":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/clone/trait.Clone.html\" title=\"trait core::clone::Clone\">Clone</a> for <a class=\"enum\" href=\"uu_install/enum.MainFunction.html\" title=\"enum uu_install::MainFunction\">MainFunction</a>"]],
"uu_kill":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/clone/trait.Clone.html\" title=\"trait core::clone::Clone\">Clone</a> for <a class=\"enum\" href=\"uu_kill/enum.Mode.html\" title=\"enum uu_kill::Mode\">Mode</a>"]],
+1
View File
@@ -1,5 +1,6 @@
(function() {var implementors = {
"uu_cp":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/fmt/trait.Debug.html\" title=\"trait core::fmt::Debug\">Debug</a> for <a class=\"enum\" href=\"uu_cp/enum.Preserve.html\" title=\"enum uu_cp::Preserve\">Preserve</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/fmt/trait.Debug.html\" title=\"trait core::fmt::Debug\">Debug</a> for <a class=\"struct\" href=\"uu_cp/struct.Attributes.html\" title=\"struct uu_cp::Attributes\">Attributes</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/fmt/trait.Debug.html\" title=\"trait core::fmt::Debug\">Debug</a> for <a class=\"enum\" href=\"uu_cp/enum.Error.html\" title=\"enum uu_cp::Error\">Error</a>"]],
"uu_dd":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/fmt/trait.Debug.html\" title=\"trait core::fmt::Debug\">Debug</a> for <a class=\"struct\" href=\"uu_dd/struct.Alarm.html\" title=\"struct uu_dd::Alarm\">Alarm</a>"]],
"uu_dircolors":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/fmt/trait.Debug.html\" title=\"trait core::fmt::Debug\">Debug</a> for <a class=\"enum\" href=\"uu_dircolors/enum.OutputFmt.html\" title=\"enum uu_dircolors::OutputFmt\">OutputFmt</a>"]],
"uu_factor":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/fmt/trait.Debug.html\" title=\"trait core::fmt::Debug\">Debug</a> for <a class=\"struct\" href=\"uu_factor/struct.Factors.html\" title=\"struct uu_factor::Factors\">Factors</a>"]],
"uu_ln":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.70.0/core/fmt/trait.Debug.html\" title=\"trait core::fmt::Debug\">Debug</a> for <a class=\"enum\" href=\"uu_ln/enum.OverwriteMode.html\" title=\"enum uu_ln::OverwriteMode\">OverwriteMode</a>"]],
@@ -2,6 +2,7 @@
"uu_base32":[["impl Freeze for <a class=\"struct\" href=\"uu_base32/base_common/struct.Config.html\" title=\"struct uu_base32::base_common::Config\">Config</a>",1,["uu_base32::base_common::Config"]]],
"uu_cp":[["impl Freeze for <a class=\"enum\" href=\"uu_cp/enum.Error.html\" title=\"enum uu_cp::Error\">Error</a>",1,["uu_cp::Error"]],["impl Freeze for <a class=\"enum\" href=\"uu_cp/enum.ClobberMode.html\" title=\"enum uu_cp::ClobberMode\">ClobberMode</a>",1,["uu_cp::ClobberMode"]],["impl Freeze for <a class=\"enum\" href=\"uu_cp/enum.OverwriteMode.html\" title=\"enum uu_cp::OverwriteMode\">OverwriteMode</a>",1,["uu_cp::OverwriteMode"]],["impl Freeze for <a class=\"enum\" href=\"uu_cp/enum.ReflinkMode.html\" title=\"enum uu_cp::ReflinkMode\">ReflinkMode</a>",1,["uu_cp::ReflinkMode"]],["impl Freeze for <a class=\"enum\" href=\"uu_cp/enum.SparseMode.html\" title=\"enum uu_cp::SparseMode\">SparseMode</a>",1,["uu_cp::SparseMode"]],["impl Freeze for <a class=\"enum\" href=\"uu_cp/enum.TargetType.html\" title=\"enum uu_cp::TargetType\">TargetType</a>",1,["uu_cp::TargetType"]],["impl Freeze for <a class=\"enum\" href=\"uu_cp/enum.CopyMode.html\" title=\"enum uu_cp::CopyMode\">CopyMode</a>",1,["uu_cp::CopyMode"]],["impl Freeze for <a class=\"struct\" href=\"uu_cp/struct.Attributes.html\" title=\"struct uu_cp::Attributes\">Attributes</a>",1,["uu_cp::Attributes"]],["impl Freeze for <a class=\"enum\" href=\"uu_cp/enum.Preserve.html\" title=\"enum uu_cp::Preserve\">Preserve</a>",1,["uu_cp::Preserve"]],["impl Freeze for <a class=\"struct\" href=\"uu_cp/struct.Options.html\" title=\"struct uu_cp::Options\">Options</a>",1,["uu_cp::Options"]]],
"uu_csplit":[["impl Freeze for <a class=\"struct\" href=\"uu_csplit/struct.CsplitOptions.html\" title=\"struct uu_csplit::CsplitOptions\">CsplitOptions</a>",1,["uu_csplit::CsplitOptions"]]],
"uu_dd":[["impl Freeze for <a class=\"struct\" href=\"uu_dd/struct.Alarm.html\" title=\"struct uu_dd::Alarm\">Alarm</a>",1,["uu_dd::Alarm"]]],
"uu_dircolors":[["impl Freeze for <a class=\"enum\" href=\"uu_dircolors/enum.OutputFmt.html\" title=\"enum uu_dircolors::OutputFmt\">OutputFmt</a>",1,["uu_dircolors::OutputFmt"]]],
"uu_factor":[["impl !Freeze for <a class=\"struct\" href=\"uu_factor/struct.Factors.html\" title=\"struct uu_factor::Factors\">Factors</a>",1,["uu_factor::factor::Factors"]]],
"uu_fmt":[["impl Freeze for <a class=\"struct\" href=\"uu_fmt/struct.FmtOptions.html\" title=\"struct uu_fmt::FmtOptions\">FmtOptions</a>",1,["uu_fmt::FmtOptions"]]],
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -116,7 +116,7 @@ var searchIndex = JSON.parse('{\
"uu_csplit":{"doc":"","t":"DLLFLLLLLFF","n":["CsplitOptions","borrow","borrow_mut","csplit","from","into","try_from","try_into","type_id","uu_app","uumain"],"q":[[0,"uu_csplit"]],"d":["Command line options for csplit.","","","Splits a file into severals according to the command line …","Returns the argument unchanged.","Calls <code>U::from(self)</code>.","","","","",""],"i":[0,1,1,0,1,1,1,1,1,0,0],"f":[0,[[]],[[]],[[1,[2,[0]],3],[[4,[0]]]],[[]],[[]],[[],4],[[],4],[[],5],[[],6],[7,8]],"c":[],"p":[[3,"CsplitOptions"],[3,"Vec"],[8,"BufRead"],[4,"Result"],[3,"TypeId"],[3,"Command"],[8,"Args"],[15,"i32"]]},\
"uu_cut":{"doc":"","t":"FF","n":["uu_app","uumain"],"q":[[0,"uu_cut"]],"d":["",""],"i":[0,0],"f":[[[],1],[2,3]],"c":[],"p":[[3,"Command"],[8,"Args"],[15,"i32"]]},\
"uu_date":{"doc":"","t":"FF","n":["uu_app","uumain"],"q":[[0,"uu_date"]],"d":["",""],"i":[0,0],"f":[[[],1],[2,3]],"c":[],"p":[[3,"Command"],[8,"Args"],[15,"i32"]]},\
"uu_dd":{"doc":"","t":"FF","n":["uu_app","uumain"],"q":[[0,"uu_dd"]],"d":["",""],"i":[0,0],"f":[[[],1],[2,3]],"c":[],"p":[[3,"Command"],[8,"Args"],[15,"i32"]]},\
"uu_dd":{"doc":"","t":"DLLLLLLLLLLLLLFFL","n":["Alarm","borrow","borrow_mut","clone","clone_into","fmt","from","get_interval","into","is_triggered","to_owned","try_from","try_into","type_id","uu_app","uumain","with_interval"],"q":[[0,"uu_dd"]],"d":["A timer which triggers on a given interval","","","","","","Returns the argument unchanged.","","Calls <code>U::from(self)</code>.","","","","","","","",""],"i":[0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1],"f":[0,[[]],[[]],[1,1],[[]],[[1,2],3],[[]],[1,4],[[]],[1,5],[[]],[[],6],[[],6],[[],7],[[],8],[9,10],[4,1]],"c":[],"p":[[3,"Alarm"],[3,"Formatter"],[6,"Result"],[3,"Duration"],[15,"bool"],[4,"Result"],[3,"TypeId"],[3,"Command"],[8,"Args"],[15,"i32"]]},\
"uu_df":{"doc":"","t":"FF","n":["uu_app","uumain"],"q":[[0,"uu_df"]],"d":["",""],"i":[0,0],"f":[[[],1],[2,3]],"c":[],"p":[[3,"Command"],[8,"Args"],[15,"i32"]]},\
"uu_dir":{"doc":"","t":"FF","n":["uu_app","uumain"],"q":[[0,"uu_dir"]],"d":["",""],"i":[0,0],"f":[[[],1],[2,3]],"c":[],"p":[[3,"Command"],[8,"Args"],[15,"i32"]]},\
"uu_dircolors":{"doc":"","t":"NNENINLLLLKLFLKKLLLFF","n":["CShell","Display","OutputFmt","Shell","StrUtils","Unknown","borrow","borrow_mut","eq","fmt","fnmatch","from","guess_syntax","into","purify","split_two","try_from","try_into","type_id","uu_app","uumain"],"q":[[0,"uu_dircolors"]],"d":["","","","","","","","","","","","Returns the argument unchanged.","","Calls <code>U::from(self)</code>.","Remove comments and trim whitespace","Like split_whitespace() but only produce 2 components","","","","",""],"i":[1,1,0,1,0,1,1,1,1,1,11,1,0,1,11,11,1,1,1,0,0],"f":[0,0,0,0,0,0,[[]],[[]],[[1,1],2],[[1,3],4],[5,2],[[]],[[],1],[[]],[[]],[[]],[[],6],[[],6],[[],7],[[],8],[9,10]],"c":[],"p":[[4,"OutputFmt"],[15,"bool"],[3,"Formatter"],[6,"Result"],[15,"str"],[4,"Result"],[3,"TypeId"],[3,"Command"],[8,"Args"],[15,"i32"],[8,"StrUtils"]]},\
+100 -8
View File
@@ -1227,6 +1227,52 @@
<a href="#1227" id="1227">1227</a>
<a href="#1228" id="1228">1228</a>
<a href="#1229" id="1229">1229</a>
<a href="#1230" id="1230">1230</a>
<a href="#1231" id="1231">1231</a>
<a href="#1232" id="1232">1232</a>
<a href="#1233" id="1233">1233</a>
<a href="#1234" id="1234">1234</a>
<a href="#1235" id="1235">1235</a>
<a href="#1236" id="1236">1236</a>
<a href="#1237" id="1237">1237</a>
<a href="#1238" id="1238">1238</a>
<a href="#1239" id="1239">1239</a>
<a href="#1240" id="1240">1240</a>
<a href="#1241" id="1241">1241</a>
<a href="#1242" id="1242">1242</a>
<a href="#1243" id="1243">1243</a>
<a href="#1244" id="1244">1244</a>
<a href="#1245" id="1245">1245</a>
<a href="#1246" id="1246">1246</a>
<a href="#1247" id="1247">1247</a>
<a href="#1248" id="1248">1248</a>
<a href="#1249" id="1249">1249</a>
<a href="#1250" id="1250">1250</a>
<a href="#1251" id="1251">1251</a>
<a href="#1252" id="1252">1252</a>
<a href="#1253" id="1253">1253</a>
<a href="#1254" id="1254">1254</a>
<a href="#1255" id="1255">1255</a>
<a href="#1256" id="1256">1256</a>
<a href="#1257" id="1257">1257</a>
<a href="#1258" id="1258">1258</a>
<a href="#1259" id="1259">1259</a>
<a href="#1260" id="1260">1260</a>
<a href="#1261" id="1261">1261</a>
<a href="#1262" id="1262">1262</a>
<a href="#1263" id="1263">1263</a>
<a href="#1264" id="1264">1264</a>
<a href="#1265" id="1265">1265</a>
<a href="#1266" id="1266">1266</a>
<a href="#1267" id="1267">1267</a>
<a href="#1268" id="1268">1268</a>
<a href="#1269" id="1269">1269</a>
<a href="#1270" id="1270">1270</a>
<a href="#1271" id="1271">1271</a>
<a href="#1272" id="1272">1272</a>
<a href="#1273" id="1273">1273</a>
<a href="#1274" id="1274">1274</a>
<a href="#1275" id="1275">1275</a>
</pre></div><pre class="rust"><code><span class="comment">// This file is part of the uutils coreutils package.
//
// (c) Tyler Steele &lt;tyler.steele@protonmail.com&gt;
@@ -1265,9 +1311,12 @@
io::{AsRawFd, FromRawFd},
};
<span class="kw">use </span>std::path::Path;
<span class="kw">use </span>std::sync::mpsc;
<span class="kw">use </span>std::sync::{
atomic::{AtomicBool, Ordering::Relaxed},
mpsc, Arc,
};
<span class="kw">use </span>std::thread;
<span class="kw">use </span>std::time;
<span class="kw">use </span>std::time::{Duration, Instant};
<span class="kw">use </span>clap::{crate_version, Arg, Command};
<span class="kw">use </span>gcd::Gcd;
@@ -1304,6 +1353,45 @@
status: <span class="prelude-ty">Option</span>&lt;StatusLevel&gt;,
}
<span class="doccomment">/// 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.
</span><span class="attr">#[derive(Debug, Clone)]
</span><span class="kw">pub struct </span>Alarm {
interval: Duration,
trigger: Arc&lt;AtomicBool&gt;,
}
<span class="kw">impl </span>Alarm {
<span class="kw">pub fn </span>with_interval(interval: Duration) -&gt; <span class="self">Self </span>{
<span class="kw">let </span>trigger = Arc::new(AtomicBool::default());
<span class="kw">let </span>weak_trigger = Arc::downgrade(<span class="kw-2">&amp;</span>trigger);
thread::spawn(<span class="kw">move </span>|| {
<span class="kw">while let </span><span class="prelude-val">Some</span>(trigger) = weak_trigger.upgrade() {
thread::sleep(interval);
trigger.store(<span class="bool-val">true</span>, Relaxed);
}
});
<span class="self">Self </span>{ interval, trigger }
}
<span class="kw">pub fn </span>is_triggered(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; bool {
<span class="self">self</span>.trigger.swap(<span class="bool-val">false</span>, Relaxed)
}
<span class="kw">pub fn </span>get_interval(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; Duration {
<span class="self">self</span>.interval
}
}
<span class="doccomment">/// A number in blocks or bytes
///
/// Some values (seek, skip, iseek, oseek) can have values either in blocks or in bytes.
@@ -1989,7 +2077,7 @@
// of its report includes the throughput in bytes per second,
// which requires knowing how long the process has been
// running.
</span><span class="kw">let </span>start = time::Instant::now();
</span><span class="kw">let </span>start = Instant::now();
<span class="comment">// A good buffer size for reading.
//
@@ -2009,7 +2097,6 @@
// information.
</span><span class="kw">let </span>(prog_tx, rx) = mpsc::channel();
<span class="kw">let </span>output_thread = thread::spawn(gen_prog_updater(rx, i.settings.status));
<span class="kw">let </span><span class="kw-2">mut </span>progress_as_secs = <span class="number">0</span>;
<span class="comment">// Optimization: if no blocks are to be written, then don&#39;t
// bother allocating any buffers.
@@ -2042,6 +2129,12 @@
// This is the max size needed.
</span><span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="macro">vec!</span>[BUF_INIT_BYTE; bsize];
<span class="comment">// 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.
</span><span class="kw">let </span>alarm = Alarm::with_interval(Duration::from_secs(<span class="number">1</span>));
<span class="comment">// Index in the input file where we are reading bytes and in
// the output file where we are writing bytes.
//
@@ -2100,9 +2193,8 @@
// error.
</span>rstat += rstat_update;
wstat += wstat_update;
<span class="kw">let </span>prog_update = ProgUpdate::new(rstat, wstat, start.elapsed(), <span class="bool-val">false</span>);
<span class="kw">if </span>prog_update.duration.as_secs() &gt;= progress_as_secs {
progress_as_secs = prog_update.duration.as_secs() + <span class="number">1</span>;
<span class="kw">if </span>alarm.is_triggered() {
<span class="kw">let </span>prog_update = ProgUpdate::new(rstat, wstat, start.elapsed(), <span class="bool-val">false</span>);
prog_tx.send(prog_update).unwrap_or(());
}
}
@@ -2114,7 +2206,7 @@
output: <span class="kw-2">&amp;mut </span>Output,
rstat: ReadStat,
wstat: WriteStat,
start: time::Instant,
start: Instant,
prog_tx: <span class="kw-2">&amp;</span>mpsc::Sender&lt;ProgUpdate&gt;,
output_thread: thread::JoinHandle&lt;T&gt;,
) -&gt; std::io::Result&lt;()&gt; {
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
window.SIDEBAR_ITEMS = {"fn":["uu_app","uumain"]};
window.SIDEBAR_ITEMS = {"fn":["uu_app","uumain"],"struct":["Alarm"]};
File diff suppressed because one or more lines are too long