Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LIFO ¶
type LIFO struct { MaxItems int64 MinItems int64 MaxIdles int64 IdleTimeout protocol.Duration // New optionally specifies a function to generate // a value when Get would otherwise return nil. // It may not be changed concurrently with calls to Get. New func() interface{} // CloseFunc optionally specifies a function to call when an item want to drop after timeout CloseFunc func(item interface{}) // contains filtered or unexported fields }
LIFO pool, i.e. the most recently Put() item will return in call Get() Such a scheme keeps CPU caches hot (in theory).
Due to LIFO behaviors and MaxItems logic can't implement with sync/atomic like sync.Pool
func (*LIFO) Clean ¶
func (p *LIFO) Clean()
Clean items but not by exact p.IdleTimeout. To improve performance we choose two window clean up. Means some idle items can live up to double of p.IdleTimeout
func (*LIFO) SetState ¶
func (p *LIFO) SetState(state PoolStatus) (pre PoolStatus)
func (*LIFO) State ¶
func (p *LIFO) State() PoolStatus
type PoolStatus ¶
type PoolStatus int32
const ( PoolStatus_Unset PoolStatus = iota PoolStatus_Running PoolStatus_Stopping PoolStatus_Stopped )
Click to show internal directories.
Click to hide internal directories.