-
Notifications
You must be signed in to change notification settings - Fork 363
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
Common Atomics and Atomic Arrays #398
Comments
I want to expand a little more on "why not value class". You mention that the objects will have no identity, but I don't see the issue with that. Couldn't we just have the
and for the point:
There's 2 solutions. One can use |
I think the atomics should also come with an |
Does this mean that atomicfu would become part of the Kotlin compiler and stdlib (with one of the solutions mentioned) rather than an external plugin? In a similar vein, are there longer term plans for multiplatform Kotlin concurrent collections (i.e. |
@kyay10 thank you for your comment! On implementing JVM atomics as value classes:
Marking
|
My point about referential equality is that it's unnecessary since normal equality will suffice (it'll compare the underlying references in case of JVM). In other words, I'd expect that WRT function mangling, maybe we want a variant of #393 that exposes the underlying type instead of a boxed type, so that one can basically say "my value class is morally the same as its underlying type, I'm just trying to have a different API than its underlying type, but Java users don't need to know about any of that". |
@rnett yes, the plan is to turn |
Some more thoughts on implementing atomics as value classes on JVM:
|
Re. JS, the KEEP says "implementation will be single threaded", which is fine, but will the atomic usages be inlined? |
And from Kotlin/kotlinx-atomicfu#493
Wouldn't it be better from a DX standpoint to always try to inline, but allow a consumer to opt-out in case the compiler reports a constraint violation? E.g. with a |
@lppedd that's actually a good point for discussion, thank you! |
Yes, inlining of |
The documentation (and implementation) for The documentation for Common and Native says this:
But the documentation for JVM, JS and Wasm says this:
For JVM this seems to be wrong, the API specification mentions For JS and Wasm, these methods are indeed implemented using |
This issue is for discussion of the proposal to introduce Common Atomic and Atomic Array types in the standard library.
The full text of the proposal is here: proposals/common-atomics.md.
The KEEP presents the proposed API for Common Atomics and Atomic Arrays and focuses on the implementation options for the JVM backend.
PR: #397
The text was updated successfully, but these errors were encountered: