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
//! Statistics for periodic peer cleanup operations.
use AtomicU64;
/// Atomic counters for tracking cleanup operation results.
///
/// `CleanupStats` is used during periodic peer timeout cleanup to track
/// the number of expired entries removed. Multiple cleanup threads can
/// safely increment these counters concurrently.
///
/// # Usage
///
/// During cleanup:
/// 1. Each thread processes assigned shards
/// 2. Counters are incremented atomically as entries are removed
/// 3. After cleanup completes, stats are applied to the main tracker
///
/// # Example
///
/// ```rust,ignore
/// use torrust_actix::tracker::structs::cleanup_stats::CleanupStats;
/// use std::sync::atomic::Ordering;
///
/// let stats = CleanupStats::new();
///
/// // Increment during cleanup
/// stats.add_torrents(5);
/// stats.add_seeds(100);
/// stats.add_peers(50);
///
/// // Read final values
/// let removed_torrents = stats.torrents.load(Ordering::Relaxed);
/// ```