Documentation ¶
Overview ¶
Package gpool provides object-reusable concurrent-safe pool.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct { Expire int64 // Max idle time(ms), after which it is recycled. NewFunc func() (interface{}, error) // Callback function to create item. ExpireFunc func(interface{}) // Expired destruction function for objects. // contains filtered or unexported fields }
Object-Reusable Pool.
func New ¶
func New(expire int, newFunc NewFunc, expireFunc ...ExpireFunc) *Pool
New returns a new object pool. To ensure execution efficiency, the expiration time cannot be modified once it is set.
Expiration logistics: expire = 0 : not expired; expire < 0 : immediate expired after use; expire > 0 : timeout expired; Note that the expiration time unit is ** milliseconds **.
func (*Pool) Clear ¶
func (p *Pool) Clear()
Clear clears pool, which means it will remove all items from pool.
Click to show internal directories.
Click to hide internal directories.