pr2

package module
v0.0.0-...-72a20ff Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 9 Imported by: 21

README

pr

parallel utils

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WaitGroupKey = waitGroupKey{}

Functions

func Consume

func Consume[T any](
	ctx context.Context,
	numThread int,
	fn func(threadID int, value T) error,
	options ...ConsumeOption,
) (
	put Put[T],
	wait Wait,
)

Types

type BacklogSize

type BacklogSize int

func (BacklogSize) IsConsumeOption

func (BacklogSize) IsConsumeOption()

type ConsumeOption

type ConsumeOption interface {
	IsConsumeOption()
}

type Pool

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

func NewPool

func NewPool[T any](
	capacity uint32,
	newFunc func() T,
) *Pool[T]

func (*Pool[T]) Get

func (p *Pool[T]) Get(ptr *T) (put func() bool)

func (*Pool[T]) GetRC

func (p *Pool[T]) GetRC(ptr *T) (
	put func() bool,
	incRef func(),
)

func (*Pool[T]) Getter

func (p *Pool[T]) Getter() (
	get func(*T),
	putAll func(),
)

type Put

type Put[T any] func(T) bool

type Wait

type Wait = func(noMorePut bool) error

type WaitGroup

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

func GetWaitGroup

func GetWaitGroup(ctx context.Context) *WaitGroup

func NewWaitGroup

func NewWaitGroup(ctx context.Context) *WaitGroup

func (*WaitGroup) Add

func (w *WaitGroup) Add() (done func())

func (*WaitGroup) Cancel

func (w *WaitGroup) Cancel()

func (*WaitGroup) Deadline

func (w *WaitGroup) Deadline() (deadline time.Time, ok bool)

func (*WaitGroup) Done

func (w *WaitGroup) Done() <-chan struct{}

func (*WaitGroup) Err

func (w *WaitGroup) Err() error

func (*WaitGroup) Go

func (w *WaitGroup) Go(fn func())

func (*WaitGroup) Value

func (w *WaitGroup) Value(key any) any

func (*WaitGroup) Wait

func (w *WaitGroup) Wait()

Jump to

Keyboard shortcuts

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