sync

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferPool

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

BufferPool a wrapper under sync.Pool which holds buffers.

func NewBufferPool

func NewBufferPool(size int) *BufferPool

NewBufferPool creates new instance of BufferPool.

func (*BufferPool) Get

func (p *BufferPool) Get() *bytes.Buffer

Get returns new buffer from pool.

func (*BufferPool) Put

func (p *BufferPool) Put(b *bytes.Buffer)

Put returns buffer to pool.

type ErrOnce

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

ErrOnce we same as sync.Once but require a function which can return an error. This error will be hold inside this type and return every time when someone call `Do` method.

func (*ErrOnce) Do

func (e *ErrOnce) Do(fn func() error) error

Do doing the stuff.

type ErrOnceWithValue

type ErrOnceWithValue[T any] struct {
	// contains filtered or unexported fields
}

ErrOnceWithValue we same as ErrOnce but holds the value as well.

func (*ErrOnceWithValue[T]) Do

func (e *ErrOnceWithValue[T]) Do(fn func() (T, error)) (T, error)

Do doing the stuff.

Jump to

Keyboard shortcuts

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