20 lines
356 B
Go
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...) {
|
|
}
|
|
}
|