added Flush function
This commit is contained in:
parent
cc9a4bb6ca
commit
9696f7d42b
11
utils.go
11
utils.go
@ -1,10 +1,5 @@
|
|||||||
package channel
|
package channel
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func determineBufferSize[T any](channels []<-chan T) int {
|
func determineBufferSize[T any](channels []<-chan T) int {
|
||||||
if len(channels) == 0 {
|
if len(channels) == 0 {
|
||||||
return 0
|
return 0
|
||||||
@ -16,3 +11,9 @@ func determineBufferSize[T any](channels []<-chan T) int {
|
|||||||
}
|
}
|
||||||
return bufSize / len(channels)
|
return bufSize / len(channels)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flush consumes all values and discards them immediately
|
||||||
|
func Flush[T any](sources ...<-chan T) {
|
||||||
|
for range Merge(sources...) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user