优化OpenFileCache功能

This commit is contained in:
GoEdgeLab
2022-11-25 14:52:04 +08:00
parent e01fd20989
commit f72b49c0cc
3 changed files with 76 additions and 0 deletions

View File

@@ -62,6 +62,9 @@ func (this *OpenFileCache) Get(filename string) *OpenFile {
if consumed {
this.locker.Lock()
this.count--
// pool如果为空也不需要从列表中删除避免put时需要重新创建
this.locker.Unlock()
}
return file
@@ -148,6 +151,7 @@ func (this *OpenFileCache) CloseAll() {
this.poolMap = map[string]*OpenFilePool{}
this.poolList.Reset()
_ = this.watcher.Close()
this.count = 0
this.locker.Unlock()
}