Skip to content
/ cirque Public

A circular queue that processes jobs in parallel but returns results in FIFO

License

Notifications You must be signed in to change notification settings

sudhirj/cirque

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cirque

A circular queue that processes jobs in parallel but returns results in FIFO.

inputs := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

inputChannel, outputChannel := NewCirque(3, func(i int) int {
    time.Sleep(time.Duration(rand.Int63n(100)) * time.Millisecond)
    return i * 2
})

go func() {
    for _, i := range inputs {
        inputChannel <- i
    }
    close(inputChannel)
}()

var output []int
for i := range outputChannel {
    output = append(output, i)
}
fmt.Println(output)

// Output: [2 4 6 8 10 12 14 16 18 20]

About

A circular queue that processes jobs in parallel but returns results in FIFO

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages