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 modules, 2 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.

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