MCPcopy Create free account
hub / github.com/eth-easl/dirigent / TestAtomicMap_MultipleThreads

Function TestAtomicMap_MultipleThreads

pkg/atomic_map/atomic_map_test.go:117–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

115}
116
117func TestAtomicMap_MultipleThreads(t *testing.T) {
118 atomicMap := NewAtomicMap[string, int]()
119
120 var wg sync.WaitGroup
121
122 size := 1000
123 wg.Add(size)
124
125 for i := 0; i < size; i++ {
126 go func(idx int) {
127 key := fmt.Sprintf("key:%d", idx)
128 atomicMap.Set(key, 0)
129 atomicMap.RemoveKey(key)
130 atomicMap.Set(key, 0xbeef)
131 wg.Done()
132 }(i)
133 }
134
135 wg.Wait()
136
137 keys := atomicMap.Keys()
138 assert.Lenf(t, keys, size, "Map should have %d keys", size)
139}

Callers

nothing calls this directly

Calls 4

NewAtomicMapFunction · 0.85
RemoveKeyMethod · 0.80
KeysMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected