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

Method Get

internal/caches/open_file_pool.go:33–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31}
32
33func (this *OpenFilePool) Get() (resultFile *OpenFile, consumed bool, consumedSize int64) {
34 // 如果已经关闭,直接返回
35 if this.isClosed {
36 return nil, false, 0
37 }
38
39 select {
40 case file := <-this.c:
41 if file != nil {
42 this.usedSize -= file.size
43
44 err := file.SeekStart()
45 if err != nil {
46 _ = file.Close()
47 return nil, true, file.size
48 }
49 file.version = this.version
50
51 return file, true, file.size
52 }
53 return nil, false, 0
54 default:
55 return nil, false, 0
56 }
57}
58
59func (this *OpenFilePool) Put(file *OpenFile) bool {
60 // 如果已关闭,则不接受新的文件

Callers 8

bigIntMethod · 0.45
NewPartialRangesFromFileFunction · 0.45
openReaderMethod · 0.45
hotLoopMethod · 0.45
TestOpenFilePool_GetFunction · 0.45
ExistItemMethod · 0.45

Calls 2

SeekStartMethod · 0.80
CloseMethod · 0.65

Tested by 3

TestOpenFilePool_GetFunction · 0.36