You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#103 describes how to raise an error if Compute fails. In that example, return 0, true ensures that the 0 is not added to the map.
That works fine for Compute, but I don't see a similar approach possible for LoadOrCompute - since the valueFn doesn't have a delete return value.
So, when using LoadOrCompute, how can I ensure that if an error occurs that I don't add a zero value (or nil, etc.) to the map? I wouldn't want a concurrent thread to retrieve that and treat it as an actual good value.
TLDR: Can you please add a version of LoadOrCompute that accepts a valueFn func() (newValue V, delete bool)?
Thanks.
The text was updated successfully, but these errors were encountered:
#103 describes how to raise an error if
Compute
fails. In that example,return 0, true
ensures that the0
is not added to the map.That works fine for
Compute
, but I don't see a similar approach possible forLoadOrCompute
- since thevalueFn
doesn't have adelete
return value.So, when using
LoadOrCompute
, how can I ensure that if an error occurs that I don't add a zero value (ornil
, etc.) to the map? I wouldn't want a concurrent thread to retrieve that and treat it as an actual good value.TLDR: Can you please add a version of
LoadOrCompute
that accepts avalueFn func() (newValue V, delete bool)
?Thanks.
The text was updated successfully, but these errors were encountered: