Skip to content

Conversation

@seanmonstar
Copy link
Contributor

It useful to be able to check if the channel is closed without registered to a task.

I didn't do it in this PR because I'm unsure of the name, but it's related: as mention in #775, it would be useful to close a channel from a Sender. I'm not sure if it should be required to have a Context, like with poll_close, so that someone could signal a close in another thread, but I'm sure the name close is reserved to be the mini-future for poll_close that borrows self.

@cramertj cramertj merged commit f845c90 into rust-lang:master Mar 3, 2018
@seanmonstar
Copy link
Contributor Author

Any thoughts on the point in the description comment?

@seanmonstar seanmonstar deleted the sender-is-closed branch March 3, 2018 00:32
@cramertj
Copy link
Member

cramertj commented Mar 3, 2018

About the naming of close? Maybe close_channel?

@cramertj
Copy link
Member

cramertj commented Mar 3, 2018

Or you could keep with the pattern used in some of the other methods and have poll_close and try_close, where try_close doesn't take a task::Context.

@seanmonstar
Copy link
Contributor Author

Of course, closing an mpsc channel has no error case, so it could just be fn close_channel(&mut self) {.

@cramertj
Copy link
Member

cramertj commented Mar 3, 2018

Seems fine to me!

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