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

Method Add

tools/cache/heap.go:141–159  ·  tools/cache/heap.go::Heap.Add

Add inserts an item, and puts it in the queue. The item is updated if it already exists.

(obj interface{})

Source from the content-addressed store, hash-verified

139// Add inserts an item, and puts it in the queue. The item is updated if it
140// already exists.
141func (h *Heap) Add(obj interface{}) error {
142 key, err := h.data.keyFunc(obj)
143 if err != nil {
144 return KeyError{obj, err}
145 }
146 h.lock.Lock()
147 defer h.lock.Unlock()
148 if h.closed {
149 return fmt.Errorf(closedMsg)
150 }
151 if _, exists := h.data.items[key]; exists {
152 h.data.items[key].obj = obj
153 heap.Fix(h.data, h.data.items[key].index)
154 } else {
155 h.addIfNotPresentLocked(key, obj)
156 }
157 h.cond.Broadcast()
158 return nil
159}
160
161// Adds all the items in the list to the queue and then signals the condition
162// variable. It is useful when the caller would like to add all of the items

Callers 11

UpdateMethod · 0.95
TestHeapBasicFunction · 0.95
TestHeap_AddFunction · 0.95
TestHeap_DeleteFunction · 0.95
TestHeap_UpdateFunction · 0.95
TestHeap_GetFunction · 0.95
TestHeap_GetByKeyFunction · 0.95
TestHeap_CloseFunction · 0.95
TestHeap_ListFunction · 0.95
TestHeap_ListKeysFunction · 0.95
TestHeapAddAfterCloseFunction · 0.95

Calls 2

addIfNotPresentLockedMethod · 0.95
ErrorfMethod · 0.65

Tested by 10

TestHeapBasicFunction · 0.76
TestHeap_AddFunction · 0.76
TestHeap_DeleteFunction · 0.76
TestHeap_UpdateFunction · 0.76
TestHeap_GetFunction · 0.76
TestHeap_GetByKeyFunction · 0.76
TestHeap_CloseFunction · 0.76
TestHeap_ListFunction · 0.76
TestHeap_ListKeysFunction · 0.76
TestHeapAddAfterCloseFunction · 0.76