MCPcopy Create free account
hub / github.com/cel-expr/cel-go / release

Method release

interpreter/async.go:425–448  ·  view source on GitHub ↗
(tracker *asyncCallStateTracker)

Source from the content-addressed store, hash-verified

423}
424
425func (pool *asyncCallTrackerPool) release(tracker *asyncCallStateTracker) {
426 if tracker == nil {
427 return
428 }
429 tracker.mu.Lock()
430 // Clearing with delete reuses the backing arrays, which is ideal for the common case but pins
431 // a large allocation in the pool after a wide fan-out (e.g. an async call over a big list).
432 // Past a threshold, reallocate so the high-water-mark memory is released to the GC instead of
433 // being retained by the pooled tracker.
434 if len(tracker.calls) > trackerShrinkThreshold || len(tracker.callsByID) > trackerShrinkThreshold {
435 tracker.calls = make(map[uint64][]*asyncCallState)
436 tracker.callsByID = make(map[int64]*asyncCallState)
437 } else {
438 for k := range tracker.calls {
439 delete(tracker.calls, k)
440 }
441 for k := range tracker.callsByID {
442 delete(tracker.callsByID, k)
443 }
444 }
445 tracker.nextCallID.Store(0)
446 tracker.mu.Unlock()
447 pool.Pool.Put(tracker)
448}
449
450func newAsyncCallTrackerPool() *asyncCallTrackerPool {
451 return &asyncCallTrackerPool{

Callers 3

TestTrackerPoolShrinkFunction · 0.80
CloseMethod · 0.80

Calls

no outgoing calls

Tested by 2

TestTrackerPoolShrinkFunction · 0.64