channel/utils.go

20 lines
356 B
Go
Raw Permalink Normal View History

2022-02-09 12:10:02 +01:00
package channel
func determineBufferSize[T any](channels []<-chan T) int {
if len(channels) == 0 {
return 0
}
bufSize := 0
for _, ch := range channels {
bufSize += cap(ch)
}
return bufSize / len(channels)
}
2022-02-09 12:17:54 +01:00
// Flush consumes all values and discards them immediately
func Flush[T any](sources ...<-chan T) {
for range Merge(sources...) {
}
}