misc

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLimit is the default concurrency limit
	DefaultLimit = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrencyLimiter added in v0.12.0

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

ConcurrencyLimiter object

func NewConcurrencyLimiter added in v0.12.0

func NewConcurrencyLimiter(limit int) *ConcurrencyLimiter

NewConcurrencyLimiter allocates a new ConcurrencyLimiter

func (*ConcurrencyLimiter) Execute added in v0.12.0

func (c *ConcurrencyLimiter) Execute(job func())

Execute adds a function to the execution queue. if num of go routines allocated by this instance is < limit launch a new go routine to execute job else wait until a go routine becomes available

func (*ConcurrencyLimiter) ExecuteIndex added in v0.12.0

func (c *ConcurrencyLimiter) ExecuteIndex(index int, job func(numb int))

ExecuteIndex ExecuteIndex

func (*ConcurrencyLimiter) Loop added in v0.12.0

func (c *ConcurrencyLimiter) Loop(n int, job func(o int))

func (*ConcurrencyLimiter) Wait added in v0.12.0

func (c *ConcurrencyLimiter) Wait()

Wait will block all the previously Executed jobs completed running.

IMPORTANT: calling the Wait function while keep calling Execute leads to

un-desired race conditions

type Timeout added in v0.9.0

type Timeout struct {
	Released bool
	Occured  bool
}

func (*Timeout) Release added in v0.9.0

func (t *Timeout) Release()

func (*Timeout) Run added in v0.9.0

func (t *Timeout) Run(seconds int, callback func())

Jump to

Keyboard shortcuts

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