-
Notifications
You must be signed in to change notification settings - Fork 18.1k
proposal: sync: Map LoadOrStore interpret functions for value
#45414
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
Comments
value
value
Essentially an atomic version of:
|
CC @bcmills We can't change the existing |
@ianlancetaylor if I understand correctly the proposal is to add a special case where if To me, overloading this API by shoehorning a callback into the value Either way, though, I think this has a sharp edge. The callback function cannot block any other |
This seems like a clear duplicate of the recently declined #44159. |
Duplicate of #44159. |
Uh oh!
There was an error while loading. Please reload this page.
The proposal states:
value
more intelligently.value
is of typeFuncLit
with a single return value, then if the key does not exist in the map, it callsvalue
and stores the return value.Depending on the ambit of Go1 compatibility promise, feel free to mark this as a Go2 proposal.
Alternatively, a new method can be added to
Map
that has this behaviour built-in.The text was updated successfully, but these errors were encountered: