syncs

package
v0.0.0-...-f7b84e4 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Additional synchronization primitives

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithPreLock

func WithPreLock(opts *options)

WithPreLock option will prevent spawning goroutines if group capacity is exceeded.

Types

type ErrSizedGroup

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

ErrSizedGroup has the same role as WaitingGroup but adds a limit of the amount of goroutines started concurrently. Uses similar Go() scheduling as errgroup.Group, thread safe.

func NewErrSizedGroup

func NewErrSizedGroup(ctx context.Context, size int64, opts ...GroupOption) *ErrSizedGroup

NewErrSizedGroup makes wait group with limited size of alive goroutines.

func (*ErrSizedGroup) Go

func (g *ErrSizedGroup) Go(fn func(ctx context.Context) error)

Go calls the given function in a new goroutine. Every call will be unblocked, but some goroutines may wait.

func (*ErrSizedGroup) Wait

func (g *ErrSizedGroup) Wait() error

Wait blocks until all function calls from the Go method have returned.

type GroupOption

type GroupOption func(o *options)

GroupOption functional option type.

type SizedGroup

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

SizedGroup has the same role as WaitingGroup but adds a limit of the amount of goroutines started concurrently. Uses similar Go() scheduling as errgroup.Group, thread safe.

func NewSizedGroup

func NewSizedGroup(ctx context.Context, size int64, opts ...GroupOption) *SizedGroup

NewSizedGroup makes wait group with limited size of alive goroutines.

func (*SizedGroup) Go

func (g *SizedGroup) Go(fn func(ctx context.Context))

Go calls the given function in a new goroutine. Every call will be unblocked, but some goroutines may wait.

func (*SizedGroup) Wait

func (g *SizedGroup) Wait()

Wait blocks until all function calls from the Go method have returned.

Jump to

Keyboard shortcuts

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