>
>
> > Is there a better way?
>
> Is fn allowed to mutate the map? If not then the locking/unlocking is not
> necessary at all. If yes then there's a race between acquiring the k,v pair
> from the map under a lock and calling fn with those, now possibly obsolete
> values.
>
Even if fn does no
On Sat, Jan 7, 2017 at 2:12 AM tsuna wrote:
> Is there a better way?
Is fn allowed to mutate the map? If not then the locking/unlocking is not
necessary at all. If yes then there's a race between acquiring the k,v pair
from the map under a lock and calling fn with those, now possibly obsolete
va
Hi there,
I have a struct that contains an unexported map protected by a mutex, let’s
say something like:
type Map struct {
mtx sync.Mutex
col map[string]interface{}
}
I want to implement a ForEach method that works in O(1) space and doesn’t
hold the mutex while working on each entry. This is wh