MCPcopy Index your code
hub / github.com/dropbox/godropbox / AddOrGet

Method AddOrGet

lockstore/map.go:60–60  ·  view source on GitHub ↗

AddOrGet for atomically and serially adding a value to the map if it does not exist. If the key is already in the map, the existing value is returned and LockingMapAddFunc is never invoked. If the key does not exist (or a ValueCheckFunc is defined and returns false), the LockingMapAddFunc is called

(string, LockingMapAddFunc)

Source from the content-addressed store, hash-verified

58 // the LockingMapAddFunc is called. We guarantee that it will only ever be invoked
59 // once at a time. I.e., it is never invoked concurrently.
60 AddOrGet(string, LockingMapAddFunc) (interface{}, error)
61
62 // Set will add the value to the map if it does not exist and will overwrite
63 // the value in the map if it does exist.

Callers 3

TestAddOrGetSimpleMethod · 0.95
TestGetWithCheckFuncMethod · 0.95
TestAddOrGetHoldsLockMethod · 0.95

Implementers 2

lockingMapcontainer/concurrent/lockstore/map.go
lockingMaplockstore/map.go

Calls

no outgoing calls

Tested by 3

TestAddOrGetSimpleMethod · 0.76
TestGetWithCheckFuncMethod · 0.76
TestAddOrGetHoldsLockMethod · 0.76