diff options
| author | tv <tv@krebsco.de> | 2026-10-26 04:20:52 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-26 04:20:52 +0100 |
| commit | 7b7dcb5a77061cb69d368de263a02b5ad26fbf51 (patch) | |
| tree | d3255ce629cb60059cb55191dc206d0f64ca645e /src/files.rs | |
| parent | d668ce2ff8f308e54c1c7a2c145cb3479cab899d (diff) | |
unify lock logic
Diffstat (limited to 'src/files.rs')
| -rw-r--r-- | src/files.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/files.rs b/src/files.rs index 58fd043..4b08469 100644 --- a/src/files.rs +++ b/src/files.rs @@ -8,6 +8,7 @@ //! end and are flushed to disk before they count as done; a crash may leave the last one //! cut short, which the file's reader has to expect. +use crate::locks::MutexExt; use std::io::Write; use std::path::{Path, PathBuf}; use std::sync::{Mutex, MutexGuard}; @@ -67,9 +68,7 @@ pub(crate) struct Files { impl Files { fn lock(&self) -> MutexGuard<'_, [Counts; FileKind::ALL.len()]> { - self.counts - .lock() - .unwrap_or_else(|poisoned| poisoned.into_inner()) + self.counts.lock_or_recover() } fn count(&self, kind: FileKind, f: impl FnOnce(&mut Counts)) { |
