concurrency

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: 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 Interface

type Interface interface {

	// Use your custom sync.WaitGroup
	WithWg(wg *sync.WaitGroup) Interface

	// Use your custom sync.Mutex
	WithMt(mt *sync.Mutex) Interface

	// Set maximum worker here. Default is 1
	WithMaxWorker(maxWorker int64) Interface

	// Run the list functions with goroutine
	Do(ctx context.Context) error

	// Added function that will be run async at goroutine. This method already call c.Done() after process is complete
	AddFunc(fn func(ctx context.Context, c Interface))

	// Lock block of code. This like mt.Lock()
	Lock()

	// Unlock block of code. This like mt.Unlock()
	Unlock()

	// To flag wait group if proccess is done. This like wg.Done()
	Done()

	// Added errors if have error. This method already implement c.Lock() and c.Unlock(). The error will be returned at Do() method if exists. Recommended to use errors.NewWithCode()
	AddError(errs ...error)

	// To clear list functions
	ClearFunc()
}

func NewConcurrency

func NewConcurrency() Interface

Do concurrency proccess with custom maximum worker

Jump to

Keyboard shortcuts

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