utils

package
v0.0.0-...-f623fcb Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLimit = 100

DefaultLimit is the default Conccurrent limit

Variables

This section is empty.

Functions

func Resize

func Resize(width, height int, img *image.RGBA) *image.RGBA

Resize scales an image to new width and height using bilinear interpolation.

func Save

func Save(buf *image.RGBA, dst string) error

Save stores the current frame buffer to a newly created file.

func ScaleDown2x

func ScaleDown2x(width, height float64, buf []color.RGBA) []color.RGBA

func Timed

func Timed(name string) func()

Timed returns a function for printing out the time elapced.

Types

type Limiter

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

Limiter object

func NewLimiter

func NewLimiter(limit int) *Limiter

NewConccurLimiter allocates a new ConccurLimiter

func (*Limiter) Execute

func (c *Limiter) 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 (*Limiter) Wait

func (c *Limiter) Wait()

Wait will block all the previously Executed jobs completed running. Note that calling the Wait function while keep calling Execute leads to un-desired race conditions

type WorkerPool

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

func NewWorkerPool

func NewWorkerPool(limit uint64) *WorkerPool

func (*WorkerPool) Add

func (p *WorkerPool) Add(numTasks uint64) uint64

func (*WorkerPool) Done

func (p *WorkerPool) Done()

func (*WorkerPool) Execute

func (p *WorkerPool) Execute(f func())

func (*WorkerPool) Running

func (p *WorkerPool) Running() uint64

func (*WorkerPool) Wait

func (p *WorkerPool) Wait()

Jump to

Keyboard shortcuts

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