Skip to content

Document that SimpleStatsCounter.snapshot() may be inconsistent with concurrent updates - #8741

Closed
LubabaKhalid wants to merge 1 commit into
google:masterfrom
LubabaKhalid:simplestatscounter-thread-safety-docs
Closed

LubabaKhalid wants to merge 1 commit into
google:masterfrom
LubabaKhalid:simplestatscounter-thread-safety-docs

Conversation

@LubabaKhalid

Copy link
Copy Markdown
Contributor

SimpleStatsCounter is documented as thread-safe, but it updates its counters independently and without locking, so a snapshot taken during an update can include only part of it (for example, a load-success count without the corresponding load time). Since that's intentional for performance, this documents it rather than adding synchronization.

Fixes #2230

…h concurrent updates.

`SimpleStatsCounter` is documented as thread-safe, but it updates its counters independently
and without locking, so a snapshot taken during an update can include part of it (for example,
a load-success count without the corresponding load time). That's intentional for performance,
so document it rather than adding synchronization.
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@LubabaKhalid

Copy link
Copy Markdown
Contributor Author

@kluever could you take a look? This adds the documentation you mentioned in the issue thread.

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.

com.google.common.cache.AbstractCache.SimpleStatsCounter is NOT thread-safe

1 participant