21 lines
399 B
Go
21 lines
399 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.
|
|
// It blocks until all sources are closed
|
|
func Flush[T any](sources ...<-chan T) {
|
|
for range Merge(sources...) {
|
|
}
|
|
}
|