Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add drain method to AtomicHistogram #113

Merged
merged 1 commit into from
May 3, 2024

Conversation

rcoh
Copy link
Contributor

@rcoh rcoh commented Apr 22, 2024

Problem

I would like to use AtomicHistogram in a metrics-collection/publishing context. In order to avoid additional synchronization primitives, I need the ability to simultaneously produce a new histogram for analysis while draining all stored values from the histogram.

Some of the docs were also out of date, and I fixed those as well.

Solution

Add a drain method that uses AtomicU64::swap to reset buckets to zero as they are consumed. This method is only available on platforms where 64 bit atomics are available and is cfg-gated accordingly.

@brayniac
Copy link
Contributor

brayniac commented May 3, 2024

Thanks for opening the PR! This looks like a good addition. I appreciate the doc updates too.

@brayniac brayniac merged commit e9f60e2 into pelikan-io:main May 3, 2024
15 checks passed
@brayniac
Copy link
Contributor

brayniac commented May 3, 2024

Included in release 0.10.1 which is now live on crates.io

Thanks again for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants