5 ms·
> HTree is better for local locks if you want a safe container. > Goroutine Safety. Could somebody elaborate on these two points? Why is it a "safe container"
by songgao 11y ago
> HTree is better for local locks if you want a safe container.
> Goroutine Safety.
Could somebody elaborate on these two points? Why is it a "safe container" and how is it more "goroutine safe" than a map?
- astockwell 11y ago[Edited for clarity per downstream thread] Both refer to native maps not being safe for concurrent use (e.g. Safe for use with Go's coroutines -- Goroutine-safe)[1] [1] https://golang.org/doc/faq#atomic_maps https://golang.org/doc/faq#atomic_maps
- songgao 11y agoIf I understand correctly, you still need guarding locks for this if reading and writing at same time, or have multiple writers. Isn't this the same as for the native map?
- astockwell 11y agoIt's not clear from the code; the author probably should clarify what "Goroutine safety" means - for reads or for read/write? Your correct about the approach for native maps. EDIT: The package description punctuation is hard to grasp, but upon a second read, "Goroutine Safety." might be intended as a headline for the next line, which starts with "No." Read that way, your understanding sounds correct.
- hit9 11y agoSorry but I have typo in the documentation, the " Goroutine Safety." is the headline of following paragraph. HTree dose not guarantee the goroutine safety: > "Lock granularity depends on the use case." The docs page updated.