Skip to content

Commit

Permalink
Decrease count on drop (#2882)
Browse files Browse the repository at this point in the history
# Description
Although the `RequestSharing` structs currently don't get deleted we
should still update the caching metrics on `Drop` just to be safe.
  • Loading branch information
MartinquaXD authored Aug 12, 2024
1 parent 48de0ca commit 7cc3778
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/shared/src/request_sharing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ where
}
}

impl<A, B: Future> Drop for RequestSharing<A, B> {
fn drop(&mut self) {
let cache = self.in_flight.lock().unwrap();
Metrics::get()
.request_sharing_cached_items
.sub(cache.len() as u64);
}
}

/// Returns a shallow copy (without any pending requests)
impl<Request, Fut: Future> Clone for RequestSharing<Request, Fut> {
fn clone(&self) -> Self {
Expand Down

0 comments on commit 7cc3778

Please sign in to comment.