sync2

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT, MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

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

Limiter implements concurrent goroutine limiting.

After calling Wait or Close, no new goroutines are allowed to start.

func NewLimiter

func NewLimiter(n int) *Limiter

NewLimiter creates a new limiter with limit set to n.

func (*Limiter) Close

func (limiter *Limiter) Close()

Close waits for all running goroutines to finish and disallows new goroutines to start.

func (*Limiter) Go

func (limiter *Limiter) Go(ctx context.Context, fn func()) bool

Go tries to start fn as a goroutine. When the limit is reached it will wait until it can run it or the context is canceled.

func (*Limiter) Wait

func (limiter *Limiter) Wait()

Wait waits for all running goroutines to finish and disallows new goroutines to start.

Jump to

Keyboard shortcuts

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