shortlivedpool

package module
v0.0.0-...-78a1443 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2017 License: MIT Imports: 5 Imported by: 0

README

shortlivedpool

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	// contains filtered or unexported fields
}

type LFStack

type LFStack struct {
	// contains filtered or unexported fields
}

func NewStack

func NewStack() *LFStack

func (*LFStack) Len

func (s *LFStack) Len() int64

func (*LFStack) Pop

func (s *LFStack) Pop() (value interface{})

func (*LFStack) Push

func (s *LFStack) Push(value interface{})

type Pool

type Pool struct {
	New func() interface{}
	// contains filtered or unexported fields
}

Pool is a drop-in replacement for sync.Pool Its difference is that evicts older elements so memory can be freed

func (*Pool) Get

func (p *Pool) Get() (x interface{})

Get selects the most recent used item from the Pool, removes it from the Pool, and returns it to the caller. Get may choose to ignore the pool and treat it as empty. Callers should not assume any relation between values passed to Put and the values returned by Get.

If Get would otherwise return nil and p.New is non-nil, Get returns the result of calling p.New.

func (*Pool) Put

func (p *Pool) Put(x interface{})

Put adds x to the pool.

type SlicedStack

type SlicedStack struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SlicedStack implements a simple stack on a slice

func (*SlicedStack) Len

func (s *SlicedStack) Len() int

Len returns the number of elements in the array

func (*SlicedStack) Pop

func (s *SlicedStack) Pop() interface{}

Pop gets the last element inserted

func (*SlicedStack) Push

func (s *SlicedStack) Push(x interface{})

Put pushes en element into the stack

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL