queueActionLocked appends to the delta list for the object. Caller must lock first.
(actionType DeltaType, obj interface{})
| 305 | // queueActionLocked appends to the delta list for the object. |
| 306 | // Caller must lock first. |
| 307 | func (f *DeltaFIFO) queueActionLocked(actionType DeltaType, obj interface{}) error { |
| 308 | id, err := f.KeyOf(obj) |
| 309 | if err != nil { |
| 310 | return KeyError{obj, err} |
| 311 | } |
| 312 | |
| 313 | // If object is supposed to be deleted (last event is Deleted), |
| 314 | // then we should ignore Sync events, because it would result in |
| 315 | // recreation of this object. |
| 316 | if actionType == Sync && f.willObjectBeDeletedLocked(id) { |
| 317 | return nil |
| 318 | } |
| 319 | |
| 320 | newDeltas := append(f.items[id], Delta{actionType, obj}) |
| 321 | newDeltas = dedupDeltas(newDeltas) |
| 322 | |
| 323 | if len(newDeltas) > 0 { |
| 324 | if _, exists := f.items[id]; !exists { |
| 325 | f.queue = append(f.queue, id) |
| 326 | } |
| 327 | f.items[id] = newDeltas |
| 328 | f.cond.Broadcast() |
| 329 | } else { |
| 330 | // We need to remove this from our map (extra items in the queue are |
| 331 | // ignored if they are not in the map). |
| 332 | delete(f.items, id) |
| 333 | } |
| 334 | return nil |
| 335 | } |
| 336 | |
| 337 | // List returns a list of all the items; it returns the object |
| 338 | // from the most recent Delta. |
no test coverage detected