sync

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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