Re:Updating the Go Memory Model
by throwaway34241 on Monday July 12, 2021 @08:43PM
(#27816663)
Sure, I was imagining implementing better race semantics the way Java/C# do, by referencing certain multi-word data by pointer to avoid partial update problems. As it is now slices are 192-bit values (on 64 bit systems) embedded directly in objects that can be shared across threads, I don't know how you would efficiently update that atomically.
[ Parent
| on HN ]
Just in theory: pointer/capacity pair is atomic, then you read len non-atomically and check it's less than cap before using it. Slice header today puts len before cap, but, like, if we're dreaming.
You'd probably hit other walls. I'm def. not trying to say it's straightforward!