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

Tracking Issue for JoinHandle::is_finished #90470

Closed
7 of 8 tasks
m-ou-se opened this issue Nov 1, 2021 · 17 comments · Fixed by #95130
Closed
7 of 8 tasks

Tracking Issue for JoinHandle::is_finished #90470

m-ou-se opened this issue Nov 1, 2021 · 17 comments · Fixed by #95130
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@m-ou-se
Copy link
Member

m-ou-se commented Nov 1, 2021

Feature gate: #![feature(thread_is_running)]

Public API

impl<T> JoinHandle<T> {
    pub fn is_finshed(&self) -> bool;
}

Steps / History

Unresolved Questions

@m-ou-se m-ou-se added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. labels Nov 1, 2021
@m-ou-se
Copy link
Member Author

m-ou-se commented Feb 15, 2022

I think the unresolved questions above can be ideas for future additions, but aren't blockers for this API.

@rfcbot merge

@rfcbot
Copy link

rfcbot commented Feb 15, 2022

Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Feb 15, 2022
@joshtriplett
Copy link
Member

I feel like the comment on the PR about try_join (ignoring any naming questions) seemed right: the use case for this seems like "check is_running and then immediately join, but don't block for any appreciable amount of time".

That said, the type signature (fn try_join(self) -> Result<..., Self> would be annoying to deal with in practice, and it doesn't seem like a good idea to make it work with &self instead.

Given those constraints, this seems like a reasonable API. However, I think I'm going to submit a PR for the documentation, to steer people away from tight-polling on it, and document the intended use case.

@rfcbot reviewed

@joshtriplett
Copy link
Member

#94033

@rfcbot
Copy link

rfcbot commented Feb 16, 2022

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Feb 16, 2022
@workingjubilee
Copy link
Member

Hm. At the risk of getting philosophical, what does it mean for a thread to be "running", if this would return true when the thread is sleeping?

And did this get answered in the negative?

Wouldn't detaching the thread after pulling out the result work on platforms that don't have a non-blocking join?

@Amanieu
Copy link
Member

Amanieu commented Feb 20, 2022

I think the question that you are usually asking is "has this thread finished running" rather than "is this thread still running". Perhaps this function could be inverted and renamed to "is_finished"?

@workingjubilee
Copy link
Member

While an async method was decided against, I will note Poll uses the idiom is_ready or is_pending.

@Julian-Wollersberger
Copy link
Contributor

+1 for @Amanieu's suggestion.
Since the intended use case is more or less if !is_running() { join() }, it would be clearer to invert the function name: if is_finished() { join() }

@m-ou-se
Copy link
Member Author

m-ou-se commented Feb 24, 2022

As suggested above, let's rename to is_finished and then FCP that instead. :)

@rfcbot cancel

@rfcbot
Copy link

rfcbot commented Feb 24, 2022

@m-ou-se proposal cancelled.

@rfcbot rfcbot removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Feb 24, 2022
@madsmtm
Copy link
Contributor

madsmtm commented Feb 25, 2022

Would it make sense to document that if is_finished returns true, it is guaranteed to always return true in subsequent calls (kinda like FusedIterator)? Or is that implied implicitly?

@m-ou-se
Copy link
Member Author

m-ou-se commented Feb 25, 2022

Would it make sense to document that if is_finished returns true, it is guaranteed to always return true in subsequent calls (kinda like FusedIterator)?

Sounds good.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Mar 4, 2022
Rename JoinHandle::is_running to is_finished.

This is renaming `is_running` to `is_finished` as discussed on the tracking issue here: rust-lang#90470 (comment)

Taking some of the docs suggestions from rust-lang#94033
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Mar 4, 2022
Rename JoinHandle::is_running to is_finished.

This is renaming `is_running` to `is_finished` as discussed on the tracking issue here: rust-lang#90470 (comment)

Taking some of the docs suggestions from rust-lang#94033
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Mar 4, 2022
Rename JoinHandle::is_running to is_finished.

This is renaming `is_running` to `is_finished` as discussed on the tracking issue here: rust-lang#90470 (comment)

Taking some of the docs suggestions from rust-lang#94033
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 4, 2022
Rename JoinHandle::is_running to is_finished.

This is renaming `is_running` to `is_finished` as discussed on the tracking issue here: rust-lang#90470 (comment)

Taking some of the docs suggestions from rust-lang#94033
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 4, 2022
Rename JoinHandle::is_running to is_finished.

This is renaming `is_running` to `is_finished` as discussed on the tracking issue here: rust-lang#90470 (comment)

Taking some of the docs suggestions from rust-lang#94033
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Mar 4, 2022
Rename JoinHandle::is_running to is_finished.

This is renaming `is_running` to `is_finished` as discussed on the tracking issue here: rust-lang#90470 (comment)

Taking some of the docs suggestions from rust-lang#94033
@m-ou-se m-ou-se changed the title Tracking Issue for JoinHandle::is_running Tracking Issue for JoinHandle::is_finished Mar 9, 2022
@m-ou-se
Copy link
Member Author

m-ou-se commented Mar 9, 2022

Let's try again with the new name. Now it's is_finished() rather than is_running(). That removes any ambiguity when the thread is sleeping or blocked (not 'running' (depending on your definition), but still not finished).

@rfcbot merge

@rfcbot
Copy link

rfcbot commented Mar 9, 2022

Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Mar 9, 2022
@rfcbot
Copy link

rfcbot commented Mar 9, 2022

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Mar 19, 2022
@rfcbot
Copy link

rfcbot commented Mar 19, 2022

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Mar 24, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Mar 30, 2022
…-ou-se

Stabilize thread::is_finished

Closes rust-lang#90470.

r? `@m-ou-se`
@bors bors closed this as completed in 32c5a57 Mar 31, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants