MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / consumeHead

Method consumeHead

internal/caches/open_file_cache.go:180–210  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

178}
179
180func (this *OpenFileCache) consumeHead() {
181 var delta = 1
182
183 if this.count > 100 {
184 delta = 2
185 }
186
187 for i := 0; i < delta; i++ {
188 var head = this.poolList.Head()
189 if head == nil {
190 break
191 }
192
193 var headPool = head.Value
194 headFile, consumed, consumedSize := headPool.Get()
195 if consumed {
196 this.count--
197 this.usedSize -= consumedSize
198
199 if headFile != nil {
200 _ = headFile.Close()
201 }
202 }
203
204 if headPool.Len() == 0 {
205 delete(this.poolMap, headPool.filename)
206 this.poolList.Remove(head)
207 _ = this.watcher.Remove(headPool.filename)
208 }
209 }
210}

Callers 1

PutMethod · 0.95

Calls 5

HeadMethod · 0.80
CloseMethod · 0.65
RemoveMethod · 0.65
GetMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected