channel/utils.go

19 lines
250 B
Go
Raw Normal View History

2022-02-09 12:10:02 +01:00
package channel
import (
"context"
"time"
)
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)
}