chanx
chanx copied to clipboard
Why is Len() not accurate ?
// Len returns len of In plus len of Out plus len of buffer.
// It is not accurate and only for your evaluating approximate number of elements in this chan,
func (c *UnboundedChan[T]) Len() int {
return len(c.In) + c.BufLen() + len(c.Out)
}
And if i wanna check whether this chan is empty or not, how should i do ?
because the dim of the three values is not atomic
because the dim of the three values is not atomic
Alright then. But at last, if chan is consumed out and no more values pushed in, Len() will be 0, right?
because the dim of the three values is not atomic
Alright then. But at last, if chan is consumed out and no more values pushed in, Len() will be 0, right?
yes