-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Labels
Description
When I use InfiniteChannel, I found that Len() returned is a "case" buffered value, https://github.com/eapache/channels/blob/master/infinite_channel.go#L58
A little demo shown as bellow:
package main
import (
"fmt"
"github.com/eapache/channels"
)
func main() {
ch := make(chan int)
infiniteCh := channels.NewInfiniteChannel()
channels.Unwrap(infiniteCh, ch)
for i := 0; i < 1000; i++ {
infiniteCh.In() <- i
}
infiniteCh.Close()
fmt.Println(infiniteCh.Len())
m := 0
for _ = range ch {
m += 1
}
fmt.Println(m)
}
The output is
999
1000
It seems like we cannot simply place an expression in blocking evaluation context.