use std::time::{Duration, Instant};
pub(crate) const PATIENCE: Duration = Duration::from_secs(10);
pub(crate) fn holds_within(within: Duration, what: &str, mut holds: impl FnMut() -> bool) {
let deadline = Instant::now() + within;
while !holds() {
assert!(Instant::now() < deadline, "{what}: not within {within:?}");
std::thread::sleep(Duration::from_millis(2));
}
}
#[cfg(any(feature = "channels", feature = "jobs"))]
pub(crate) fn timed_close(store: &crate::Store) -> (crate::Result<()>, Duration) {
let began = Instant::now();
let closed = store.close();
(closed, began.elapsed())
}