GetAll returns a snapshot copy of all items currently in the tracker. The returned map is a shallow copy: modifying it will not affect the underlying tracker contents. Safe for concurrent use.
()
| 33 | // The returned map is a shallow copy: modifying it will not affect |
| 34 | // the underlying tracker contents. Safe for concurrent use. |
| 35 | func (t *Tracker[T]) GetAll() map[string]T { |
| 36 | t.mu.RLock() |
| 37 | snapshot := make(map[string]T, len(t.items)) |
| 38 | maps.Copy(snapshot, t.items) |
| 39 | t.mu.RUnlock() |
| 40 | return snapshot |
| 41 | } |
| 42 | |
| 43 | // Get returns the item stored under the given id, along with a boolean |
| 44 | // indicating whether it was found. |
no outgoing calls