Skip to content

Conversation

murfel
Copy link
Contributor

@murfel murfel commented Oct 9, 2025

Add an example, stress that different coroutines can iterate over the channel, with their own iterator instance

…he channel, with their own iterator instance
@murfel murfel requested a review from dkhalanskyjb October 9, 2025 10:41
* Iterator for a [ReceiveChannel].
* Instances of this interface are *not thread-safe* and shall not be used from concurrent coroutines.
* Instances of this interface are *not thread-safe*.
* Each iterator instance should be used by a single coroutine.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not true, it can be passed around different coroutines as long as this doesn't result in multithreaded access.

* Instances of this interface are *not thread-safe*.
* Each iterator instance should be created and used by a single coroutine.
*
* An example usage:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you describe the sequence of events where this sample would answer a question a user may realistically have? It neither explains the next()/hasNext() interplay useful in deeply technical cases where you'd manipulate ChannelIterator manually, nor does it spell out "hey, this is not the class that you need to use manually, just write for (... in ...) instead" if that was the intention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants