utils

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFutureClosed = errors.New("future has closed")

Functions

func NormalizeDuration added in v0.0.4

func NormalizeDuration(d time.Duration) string

func UnsafeToBytes

func UnsafeToBytes(s string) []byte

func UnsafeToString

func UnsafeToString(b []byte) string

Types

type Copool

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

func NewCopool

func NewCopool(cap uint) *Copool

func (*Copool) CtxGo

func (cp *Copool) CtxGo(ctx *context.Context, f func())

CtxGo executes f and accepts the context.

func (*Copool) Go

func (cp *Copool) Go(f func())

Go executes f.

func (*Copool) SetPanicHandler

func (cp *Copool) SetPanicHandler(f func(*context.Context, interface{})) *Copool

SetPanicHandler sets the panic handler.

type Future

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

func NewFuture

func NewFuture[T any]() Future[T]

func (*Future[T]) Get

func (f *Future[T]) Get() (T, error)

func (*Future[T]) Set

func (f *Future[T]) Set(result T)

type ObjectPool

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

func NewObjectPool

func NewObjectPool[T any](creator func() T) *ObjectPool[T]

func (*ObjectPool[T]) Get

func (p *ObjectPool[T]) Get() T

func (*ObjectPool[T]) Put

func (p *ObjectPool[T]) Put(x T)

type Queue

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

thread safe Queue

func NewQueue

func NewQueue[T any]() *Queue[T]

func (*Queue[T]) Len

func (q *Queue[T]) Len() int32

func (*Queue[T]) Peak

func (q *Queue[T]) Peak() T

func (*Queue[T]) PeakAndTake

func (q *Queue[T]) PeakAndTake() T

func (*Queue[T]) Put

func (q *Queue[T]) Put(data T)

type RC

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

func (*RC) Decrease

func (c *RC) Decrease()

func (*RC) Increase

func (c *RC) Increase()

func (*RC) Set

func (c *RC) Set(val int)

func (*RC) Value

func (c *RC) Value() int

Jump to

Keyboard shortcuts

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