pr

package module
v0.0.0-...-adb0578 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 11 Imported by: 2

README

pr

parallel utils

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Consume

func Consume[T any](
	parentWt *WaitTree,
	numThread int,
	fn func(threadID int, value T) error,
	options ...ConsumeOption,
) (
	put Put[T],
	wait Wait,
)

Types

type BackgroundCtx

type BackgroundCtx func() context.Context

func (BackgroundCtx) IsWaitTreeOption

func (_ BackgroundCtx) IsWaitTreeOption()

type BacklogSize

type BacklogSize int

func (BacklogSize) IsConsumeOption

func (_ BacklogSize) IsConsumeOption()

type ConsumeOption

type ConsumeOption interface {
	IsConsumeOption()
}

type ID

type ID string

func (ID) IsWaitTreeOption

func (_ ID) IsWaitTreeOption()

type Pool

type Pool[T any] struct {
	Callers [][]byte

	LogCallers bool
	// contains filtered or unexported fields
}

func NewPool

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

func (*Pool[T]) Get

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

func (*Pool[T]) GetRC

func (p *Pool[T]) GetRC() (
	value 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 Timeout

type Timeout time.Duration

func (Timeout) IsWaitTreeOption

func (_ Timeout) IsWaitTreeOption()

type Trace

type Trace bool

func (Trace) IsWaitTreeOption

func (_ Trace) IsWaitTreeOption()

type Wait

type Wait = func(noMorePut bool) error

type WaitTree

type WaitTree struct {
	ID     string
	Ctx    context.Context
	Cancel func()
	// contains filtered or unexported fields
}

func NewRootWaitTree

func NewRootWaitTree(
	options ...WaitTreeOption,
) *WaitTree

func NewWaitTree

func NewWaitTree(
	parent *WaitTree,
	options ...WaitTreeOption,
) *WaitTree

func (*WaitTree) Add

func (t *WaitTree) Add() (done func())

func (*WaitTree) Go

func (t *WaitTree) Go(fn func())

func (*WaitTree) PrintTraces

func (t *WaitTree) PrintTraces(w io.Writer)

func (*WaitTree) Wait

func (t *WaitTree) Wait()

type WaitTreeOption

type WaitTreeOption interface {
	IsWaitTreeOption()
}

Jump to

Keyboard shortcuts

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