Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrItemUnavailable Error when an item cannot be allocated fromt the pool
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct { Item interface{} // contains filtered or unexported fields }
Item wrapper type for items stored in pool
type ItemFactory ¶
type ItemFactory func() (interface{}, error)
ItemFactory function to create an item for the pool
type Pool ¶
type Pool interface { // Borrow item from pool, returns ErrItemUnavailable if none available Borrow() (*Item, error) // Borrow item from pool, wait timeout. If timeout < 0 wait indefinitely. Returns ErrItemUnavailable if object not available BorrowWait(timeout time.Duration) (*Item, error) // Return item back to pool Return(item *Item) error // Remove removes the object from the pool Remove(item *Item) error //Returns the current number of items borrowed Borrowed() int //Returns the current number of items in the pool (not borrowed) Idle() int }
Pool interface for pooling arbitrary objects
Click to show internal directories.
Click to hide internal directories.