hyper_client_pool/executor/
transaction_counter.rs

1use raii_counter::WeakCounter;
2
3pub struct TransactionCounter {
4    transaction_counter: WeakCounter,
5    worker_counter: WeakCounter,
6}
7
8impl TransactionCounter {
9    pub(crate) fn new(
10        transaction_counter: WeakCounter,
11        worker_counter: WeakCounter,
12    ) -> TransactionCounter {
13        TransactionCounter {
14            transaction_counter,
15            worker_counter,
16        }
17    }
18
19    /// Get the count of transactions
20    pub fn count(&self) -> usize {
21        self.transaction_counter.count()
22    }
23
24    /// Checks that the Worker is still alive
25    /// The strong counter is held by the Worker
26    pub fn is_valid(&self) -> bool {
27        self.worker_counter.count() > 0
28    }
29}