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

Added is_closed method #35

Merged
merged 1 commit into from
May 23, 2024
Merged

Added is_closed method #35

merged 1 commit into from
May 23, 2024

Conversation

fulmicoton
Copy link
Contributor

This adds a is_closed method to the oneshot Sender.

The naming was copied from tokio's oneshot.
This PR was motivated by the following need.

A thread pool executor queues FnOnce()->T on a thread pool.
The method used to schedule the execution of such a function returns a Receiver.

When the execution of a function arrives, is_closed makes it possible on the executor side to detect that no one is actually waiting on the result anymore, and the executor can skip the execution of the function entirely.

@faern
Copy link
Owner

faern commented May 8, 2024

Nice. Thank you for the PR. I think this sounds like a nice method to have. Can you please rebase this on latest main to get the CI working. I would also appreciate if you could document the SAFETY and ORDERING properties of the new code, like all other code in this library.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@faern faern merged commit ccd8228 into faern:main May 23, 2024
10 checks passed
@faern
Copy link
Owner

faern commented May 23, 2024

Thanks for the contribution! This seems like a useful method in some cases :)

@fulmicoton
Copy link
Contributor Author

Is there a release planned @faern ?

@faern
Copy link
Owner

faern commented May 24, 2024

Yes! I just published 0.1.7:

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