Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement FusedStream for Receiver #3

Closed
fogti opened this issue Jun 12, 2020 · 4 comments · Fixed by #30
Closed

implement FusedStream for Receiver #3

fogti opened this issue Jun 12, 2020 · 4 comments · Fixed by #30

Comments

@fogti
Copy link
Member

fogti commented Jun 12, 2020

as Receiver can detect if the channel is closed, it probably can implement FusedStream...
see also concurrent_queue::ConcurrentQueue::is_closed

@fogti
Copy link
Member Author

fogti commented Jun 12, 2020

impl<T> FusedStream for Receiver<T> {
    fn is_terminated(&self) {
        self.channel.queue.is_closed() && self.channel.queue.is_empty()
    }
}

@ghost
Copy link

ghost commented Jun 12, 2020

I'm curious: in what cases is FusedStream useful or used in practice?

This sounds good - just a small correction: the Receiver is terminated when the queue is closed and is empty.

@fogti
Copy link
Member Author

fogti commented Jun 12, 2020

It is i.a. used for using the futures::select! macro without needing to .fuse() the Stream.

@fogti
Copy link
Member Author

fogti commented Jan 6, 2021

As FusedStream is defined in futures-core, this wouldn't even require another dependency. It would be a really small change which increases usability.

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

Successfully merging a pull request may close this issue.

1 participant