8000 Why is Len() not accurate ? · Issue #20 · smallnest/chanx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Why is Len() not accurate ? #20
Open
@bruceauyeung

Description

@bruceauyeung
// 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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0