MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / Put

Method Put

internal/caches/open_file_pool.go:59–82  ·  view source on GitHub ↗
(file *OpenFile)

Source from the content-addressed store, hash-verified

57}
58
59func (this *OpenFilePool) Put(file *OpenFile) bool {
60 // 如果已关闭,则不接受新的文件
61 if this.isClosed {
62 _ = file.Close()
63 return false
64 }
65
66 // 检查文件版本号
67 if this.version > 0 && file.version > 0 && file.version != this.version {
68 _ = file.Close()
69 return false
70 }
71
72 // 加入Pool
73 select {
74 case this.c <- file:
75 this.usedSize += file.size
76 return true
77 default:
78 // 多余的直接关闭
79 _ = file.Close()
80 return false
81 }
82}
83
84func (this *OpenFilePool) Len() int {
85 return len(this.c)

Callers 8

CloseMethod · 0.45
bigIntMethod · 0.45
WriteToFileMethod · 0.45
hotLoopMethod · 0.45
TestOpenFilePool_GetFunction · 0.45
TestOpenFilePool_CloseFunction · 0.45

Calls 1

CloseMethod · 0.65

Tested by 4

TestOpenFilePool_GetFunction · 0.36
TestOpenFilePool_CloseFunction · 0.36