Skip to content

var and Atomic #2062

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

Closed
rewlad opened this issue May 26, 2020 · 1 comment · Fixed by #2063
Closed

var and Atomic #2062

rewlad opened this issue May 26, 2020 · 1 comment · Fixed by #2063
Assignees
Labels
bug docs KDoc and API reference

Comments

@rewlad
Copy link

rewlad commented May 26, 2020

Why is it written var counter = AtomicInteger()?
It seems to be val, because counter itself is not mutated, but the value of atomic does.
And this way we leave someone possibility to do counter = in an unsafe way.
And we can not make CI rule to warn of unsafe global mutable state.
On the other hand may be someone (who does not know what is Atomic*) needs to see, that counter has mutable meaning.

https://kotlinlang.org/docs/reference/coroutines/shared-mutable-state-and-concurrency.html

@elizarov
Copy link
Contributor

That's a bug. Thanks for noticing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug docs KDoc and API reference
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants