Re:Some Thoughts on Zig
by scoutt on Friday July 22, 2022 @03:13AM
(#32189418)
I imagine you can have one thread modifying the vector while trying to read its length from another thread.
[ Parent
| on HN ]
Re:Some Thoughts on Zig
by ArrayBoundCheck on Friday July 22, 2022 @05:31PM
(#32197353)
Noone should imagine that. You definitely don't want two threads accessing the same vec or array at one time. Maybe if there's a lock
Re:Some Thoughts on Zig
by nickitolas on Saturday July 23, 2022 @03:06PM
(#32206510)
If it's read only, you can definitely want that, right? As long as the elements are Sync. And it should work (You might have a problem with the cleanup, but Arc or scoped threads should handle that). The problem is when one is a mutable reference, like in this case. AIUI you could have a single mutable reference to an element be used from another thread (For example, a scoped thread) if the elements of the Vec are Sync