MCPcopy
hub / github.com/kubernetes/client-go / BulkAdd

Method BulkAdd

tools/cache/heap.go:164–184  ·  view source on GitHub ↗

Adds all the items in the list to the queue and then signals the condition variable. It is useful when the caller would like to add all of the items to the queue before consumer starts processing them.

(list []interface{})

Source from the content-addressed store, hash-verified

162// variable. It is useful when the caller would like to add all of the items
163// to the queue before consumer starts processing them.
164func (h *Heap) BulkAdd(list []interface{}) error {
165 h.lock.Lock()
166 defer h.lock.Unlock()
167 if h.closed {
168 return fmt.Errorf(closedMsg)
169 }
170 for _, obj := range list {
171 key, err := h.data.keyFunc(obj)
172 if err != nil {
173 return KeyError{obj, err}
174 }
175 if _, exists := h.data.items[key]; exists {
176 h.data.items[key].obj = obj
177 heap.Fix(h.data, h.data.items[key].index)
178 } else {
179 h.addIfNotPresentLocked(key, obj)
180 }
181 }
182 h.cond.Broadcast()
183 return nil
184}
185
186// AddIfNotPresent inserts an item, and puts it in the queue. If an item with
187// the key is present in the map, no changes is made to the item.

Callers 2

TestHeap_BulkAddFunction · 0.95
TestHeapAddAfterCloseFunction · 0.95

Calls 2

addIfNotPresentLockedMethod · 0.95
ErrorfMethod · 0.65

Tested by 2

TestHeap_BulkAddFunction · 0.76
TestHeapAddAfterCloseFunction · 0.76