Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
24 lines (20 sloc) 356 Bytes
package job
var jobIDSource <-chan int
func init() {
jobIDSource = func() <-chan int {
out := make(chan int, 10)
go func() {
var jobID int
for {
jobID++
out <- jobID
}
}()
return out
}()
}
// GetNumber is a source of safe monotonically increasing integers
// for use in Job ids.
func GetNumber() int {
return <-jobIDSource
}