recycler

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

recycler

Index

Constants

View Source
const (
	NewTimerDefaultDuration time.Duration = time.Minute
	TimerRecyclerBacklog    int           = 128
)
View Source
const (
	BytebufRecyclerBacklog int = 128
)

Variables

View Source
var BytebufRecycler = NewRecycler(
	BytebufRecyclerBacklog,
	func() interface{} {
		return bytes.NewBuffer(nil)
	},
	"bytebuf_recycler",
)
View Source
var RecyclerBacklogDefault int = 5
View Source
var RecyclerMgr = &recyclerMgr{
	recyclers: make(map[interface{}]*Recycler),
	lock:      new(sync.Mutex),
}
View Source
var TimerRecycler = NewRecycler(
	TimerRecyclerBacklog,
	func() interface{} {
		return time.NewTimer(NewTimerDefaultDuration)
	},
	"timer_recycler",
)

Functions

func AllocBytebuf

func AllocBytebuf() *bytes.Buffer

func FreeBytebuf

func FreeBytebuf(buf *bytes.Buffer)

func GetTimer

func GetTimer(timeout time.Duration) *time.Timer

func GiveTimer

func GiveTimer(t *time.Timer)

Types

type Recycler

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

func NewRecycler

func NewRecycler(backlog int, ocf func() interface{}, name string) *Recycler

func (*Recycler) Close

func (this *Recycler) Close()

func (*Recycler) Get

func (this *Recycler) Get() interface{}

func (*Recycler) Give

func (this *Recycler) Give(i interface{})

Jump to

Keyboard shortcuts

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