MCPcopy
hub / github.com/caddyserver/caddy / Range

Method Range

usagepool.go:149–164  ·  view source on GitHub ↗

Range iterates the pool similarly to how sync.Map.Range() does: it calls f for every key in the pool, and if f returns false, iteration is stopped. Ranging does not affect usage counts. This method is somewhat naive and acquires a read lock on the entire pool during iteration, so do your best to ma

(f func(key, value any) bool)

Source from the content-addressed store, hash-verified

147// entire pool during iteration, so do your best to make f() really
148// fast, m'kay?
149func (up *UsagePool) Range(f func(key, value any) bool) {
150 up.RLock()
151 defer up.RUnlock()
152 for key, upv := range up.pool {
153 upv.RLock()
154 if upv.err != nil {
155 upv.RUnlock()
156 continue
157 }
158 val := upv.value
159 upv.RUnlock()
160 if !f(key, val) {
161 break
162 }
163 }
164}
165
166// Delete decrements the usage count for key and removes the
167// value from the underlying map if the usage is 0. It returns

Callers 2

handleUpstreamsMethod · 0.80
getInFlightRequestsFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected