19 lines
250 B
Go
19 lines
250 B
Go
|
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)
|
||
|
}
|