You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
concurrent-stream: High Throughput Generics Stream/Pipeline/Channel Processing in Go.
go get github.com/planxnx/concurrent-stream
Examples
Basic
results:=make(chanint)
stream:=cstream.NewStream(ctx, 8, results)
gofunc() {
fori:=0; i<10; i++ {
i:=istream.Go(func() int {
returnexpensiveFunc(i)
})
}
// Should be called to close the stream// after all tasks are submitted.stream.Close()
}()
wg:= sync.WaitGroup{}
wg.Add(1)
gofunc() {
deferwg.Done()
forresult:=rangeresults {
fmt.Println(result)
}
}()
// Wait for all tasks to finish.iferr:=stream.Wait(); err!=nil {
panic(err)
}
close(results)
wg.Wait()