MCPcopy Create free account
hub / github.com/Azure/peerd / NewSyncMap

Function NewSyncMap

pkg/cache/syncmap.go:66–74  ·  view source on GitHub ↗

NewSyncMap creates a new SyncMap with the specified maximum number of entries. If the maximum number of entries is less than or equal to 0, it will be set to 1.

(maxEntries int)

Source from the content-addressed store, hash-verified

64// NewSyncMap creates a new SyncMap with the specified maximum number of entries.
65// If the maximum number of entries is less than or equal to 0, it will be set to 1.
66func NewSyncMap(maxEntries int) *SyncMap {
67 if maxEntries <= 0 {
68 maxEntries = 1
69 }
70 return &SyncMap{mapObj: &map[string]interface{}{},
71 lock: &sync.RWMutex{},
72 capacity: maxEntries,
73 evictionPercentage: defaultEvictionPercentage}
74}

Callers 6

TestSyncMapBaseFunction · 0.85
TestSyncMapAddEvictFunction · 0.85
TestSyncMapAddDeleteFunction · 0.85
TestSyncMapUpdateFunction · 0.85
BenchmarkSyncMapFunction · 0.85
NewCacheFunction · 0.85

Calls

no outgoing calls

Tested by 5

TestSyncMapBaseFunction · 0.68
TestSyncMapAddEvictFunction · 0.68
TestSyncMapAddDeleteFunction · 0.68
TestSyncMapUpdateFunction · 0.68
BenchmarkSyncMapFunction · 0.68