/
githubmirror
/
GoFrame
Обзор
Документация
Войти
/
githubmirror
/
GoFrame
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
os/gfpool/gfpool.go
41 строка
1 KB
houseme
[feature] improve code gfile gcfg
15 ноя 2021, 15:26
15 ноя 2021, 15:26
b664982
Код
Авторство
О чём код?
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. // // This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, // You can obtain one at https://github.com/gogf/gf. // Package gfpool provides io-reusable pool for file pointer. package gfpool import ( "os" "time" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gpool" "github.com/gogf/gf/v2/container/gtype" ) // Pool pointer pool. type Pool struct { id *gtype.Int // Pool id, which is used to mark this pool whether recreated. pool *gpool.Pool // Underlying pool. init *gtype.Bool // Whether initialized, used for marking this file added to fsnotify, and it can only be added just once. ttl time.Duration // Time to live for file pointer items. } // File is an item in the pool. type File struct { *os.File // Underlying file pointer. stat os.FileInfo // State of current file pointer. pid int // Belonging pool id, which is set when file pointer created. It's used to check whether the pool is recreated. pool *Pool // Belonging ool. flag int // Flash for opening file. perm os.FileMode // Permission for opening file. path string // Absolute path of the file. } var ( // Global file pointer pool. pools = gmap.NewStrAnyMap(true) )