I think using standard sync'ed map may be bad idea for this use case (write-only access), especially taking into account that it's optimized for read access and stable keys, so each write will acquire mutex anyway.
if nothing is read from that map during the threads run, it should be probably much better to assign single map for every thread and at the end, copy/merge the results to single "output" using mutex or rwmutex. This way you can acquire mutex once per thread, acquiring it for every write from multiple threads (which is what sync/map will do) is a performance killer. W dniu piątek, 13 października 2017 20:05:56 UTC+2 użytkownik Alex Buchanan napisał: > > Basically, I want to spawn a goroutine per object, objects have unique > IDs, and I want each routine to write its results to a shared map. Nothing > will be reading from the map while the goroutines are running. > > Is this safe? > > Thanks > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.