Skip to content
/ workqueue Public

Package workqueue provides a simple means of queuing any type of work.

License

Notifications You must be signed in to change notification settings

nesv/workqueue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

workqueue

Package workqueue provides a means to queueing work.

Documentation

GoDoc

Example

package main

import (
	"fmt"
	"sync"

	workqueue "go.nesv.ca/workqueue/v2"
)

func main() {
	// Create a new Queue.
	q := workqueue.New(1024)

	// Use a sync.WaitGroup to make sure we process all work before
	// exiting.
	var wg sync.WaitGroup

	// Now, let's do some work.
	for i := 0; i < 2048; i++ {
		wg.Add(1)
		go func(v int) {
			q <- func() {
				fmt.Println(v)
				wg.Done()
			}
		}(i)
	}

	// Wait for all the work to be done, then close the Queue.
	wg.Wait()
	close(q)
}

About

Package workqueue provides a simple means of queuing any type of work.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages