https://github.com/nesv/workqueue
Package workqueue provides a simple means of queuing any type of work.
https://github.com/nesv/workqueue
Last synced: 6 months ago
JSON representation
Package workqueue provides a simple means of queuing any type of work.
- Host: GitHub
- URL: https://github.com/nesv/workqueue
- Owner: nesv
- License: apache-2.0
- Created: 2016-10-04T14:48:25.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-02-19T18:17:32.000Z (over 3 years ago)
- Last Synced: 2024-10-21T18:04:13.945Z (over 1 year ago)
- Language: Go
- Size: 12.7 KB
- Stars: 7
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# workqueue
Package workqueue provides a means to queueing work.
## Documentation
[GoDoc](https://pkg.go.dev/go.nesv.ca/workqueue/v2)
## Example
```go
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)
}
```