channel/utils.go
2022-02-09 12:17:54 +01:00

20 lines
356 B
Go

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)
}
// Flush consumes all values and discards them immediately
func Flush[T any](sources ...<-chan T) {
for range Merge(sources...) {
}
}