added Flush function

This commit is contained in:
Tordarus 2022-02-09 12:17:54 +01:00
parent cc9a4bb6ca
commit 9696f7d42b

View File

@ -1,10 +1,5 @@
package channel
import (
"context"
"time"
)
func determineBufferSize[T any](channels []<-chan T) int {
if len(channels) == 0 {
return 0
@ -16,3 +11,9 @@ func determineBufferSize[T any](channels []<-chan T) int {
}
return bufSize / len(channels)
}
// Flush consumes all values and discards them immediately
func Flush[T any](sources ...<-chan T) {
for range Merge(sources...) {
}
}