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
|
|
|
|
2022-02-09 12:19:19 +01:00
|
|
|
// Flush consumes all values and discards them immediately.
|
|
|
|
// It blocks until all sources are closed
|
2022-02-09 12:17:54 +01:00
|
|
|
func Flush[T any](sources ...<-chan T) {
|
|
|
|
for range Merge(sources...) {
|
|
|
|
}
|
|
|
|
}
|