(rc *refCounter)
| 80 | } |
| 81 | |
| 82 | func (c *LRUCache) decreaseOnceFunc(rc *refCounter) func() { |
| 83 | var once sync.Once |
| 84 | return func() { |
| 85 | c.mu.Lock() |
| 86 | defer c.mu.Unlock() |
| 87 | once.Do(func() { rc.dec() }) |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | type refCounter struct { |
| 92 | onEvicted func(key string, value interface{}) |