Skip to content

ecnepsnai/qu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QU

Go Report Card Godoc Releases LICENSE

Package qu is a simple executor service. You add jobs to a queue, then run them concurrently with a configurable amount of concurrency.

Usage

queue := &qu.Queue{}

job := func(payload interface{}) {
	i := payload.(int)
	fmt.Printf("Job %d\n", i)
	time.Sleep(1 * time.Millisecond)
}

// Add 50 jobs to the queue
i := 0
for i < 50 {
	queue.Add(job, i)
	i++
}

// Go through those 50 jobs across 2 threads
queue.Run(2)