Documentation ¶
Overview ¶
Package gfpool provides io-reusable pool for file pointer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
File is an item in the pool.
func Open ¶
Open creates and returns a file item with given file path, flag and opening permission. It automatically creates an associated file pointer pool internally when it's called first time. It retrieves a file item from the file pointer pool after then.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
File pointer pool.
func New ¶
New creates and returns a file pointer pool with given file path, flag and opening permission.
Note the expiration logic: ttl = 0 : not expired; ttl < 0 : immediate expired after use; ttl > 0 : timeout expired; It is not expired in default.
func (*Pool) File ¶
File retrieves file item from the file pointer pool and returns it. It creates one if the file pointer pool is empty. Note that it should be closed when it will never be used. When it's closed, it is not really closed the underlying file pointer but put back to the file pinter pool.