1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use _start_cleaner;
use _start_cleaner;
/// Cleanup defines an implementation where expired
/// elements can be removed.
/// Start a new cleanup cycle on the given [`Cleanup`](crate::Cleanup)
/// implementation instance and returns a function to cancel the
/// cleanup cycle.
///
/// On each elapse, the map ich checked for expired
/// key-value pairs and removes them from the map.
///
/// # Example
/// ```
/// use timedmap::{TimedMap, start_cleaner};
/// use std::time::Duration;
/// use std::sync::Arc;
///
/// let tm = Arc::new(TimedMap::new());
/// tm.insert("foo", "bar", Duration::from_secs(60));
///
/// # #[cfg(feature = "tokio")]
/// # tokio_test::block_on(async {
/// let cancel = start_cleaner(tm, Duration::from_secs(10));
///
/// cancel();
/// # });
/// ```