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

std: Doc blocking behavior of LazyLock #119870

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

behnam-oneschema
Copy link

Adding notes about blocking behavior of calls that can block the current thread, similar to those on https://doc.rust-lang.org/std/sync/struct.OnceLock.html

I'm not sure if the "This method never blocks." counterparts would be desired. If so, can add those, as well.

@rustbot
Copy link
Collaborator

rustbot commented Jan 11, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cuviper (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 11, 2024
@behnam-oneschema
Copy link
Author

Fyi, @tgross35, as author of #109736.

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

Content LGTM, but could you add a blurb about this at the top-level LazyLock type? I don't think many users will read all the way down the deref.

@behnam-oneschema
Copy link
Author

Good point, @tgross35. I'll do that.

I also noticed into_inner, added in #106152, and realized that it doesn't the explain the blocking behavior, which I think is important to note as there are two valid options: a) if there's a resolution happening, block until it's done, then return a result, or b) without blocking, return a result based on the current value. From the current doc, it's not possible to tell which behavior this has, right? Wdyt?

@behnam-oneschema
Copy link
Author

Also cc @SUPERCILEX.

@tgross35
Copy link
Contributor

I don't think that can happen for into_inner right, since it takes self so there must be no other references to it

@behnam-oneschema
Copy link
Author

Uh, you're right, @tgross35. No other self-consuming methods have any note on blocking behavior. I'll leave into_inner as it is, then. Thanks!

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

LGTM with the optional nit. I can't approve workflows so somebody else will have to take a look too.

Thanks for the PR, docs improvements are always appreciated! Welcome 🙂

library/std/src/sync/lazy_lock.rs Outdated Show resolved Hide resolved
@ChrisDenton
Copy link
Member

This looks great, thanks! Could you squish your commits into one?

@behnam-oneschema
Copy link
Author

Cool! Sure, just did.

@ChrisDenton
Copy link
Member

@bors r=tgross35,ChrisDenton rollup

@bors
Copy link
Contributor

bors commented Jan 14, 2024

📌 Commit a596159 has been approved by tgross35,ChrisDenton

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 14, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 15, 2024
…-1, r=tgross35,ChrisDenton

std: Doc blocking behavior of LazyLock

Adding notes about blocking behavior of calls that can block the current thread, similar to those on https://doc.rust-lang.org/std/sync/struct.OnceLock.html

I'm not sure if the "This method never blocks." counterparts would be desired. If so, can add those, as well.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 15, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#119508 (coverage: Simplify building the coverage graph with `CoverageSuccessors`)
 - rust-lang#119818 (Silence some follow-up errors [3/x])
 - rust-lang#119870 (std: Doc blocking behavior of LazyLock)
 - rust-lang#119963 (Fix `allow_internal_unstable` for `(min_)specialization`)
 - rust-lang#119968 (Remove unused/unnecessary features)
 - rust-lang#119971 (Use `zip_eq` to enforce that things being zipped have equal sizes)
 - rust-lang#119974 (Minor `trimmed_def_paths` improvements)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 15, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#119818 (Silence some follow-up errors [3/x])
 - rust-lang#119870 (std: Doc blocking behavior of LazyLock)
 - rust-lang#119897 (`OutputTypeParameterMismatch` -> `SignatureMismatch`)
 - rust-lang#119963 (Fix `allow_internal_unstable` for `(min_)specialization`)
 - rust-lang#119971 (Use `zip_eq` to enforce that things being zipped have equal sizes)
 - rust-lang#119974 (Minor `trimmed_def_paths` improvements)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 15, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#119818 (Silence some follow-up errors [3/x])
 - rust-lang#119870 (std: Doc blocking behavior of LazyLock)
 - rust-lang#119897 (`OutputTypeParameterMismatch` -> `SignatureMismatch`)
 - rust-lang#119963 (Fix `allow_internal_unstable` for `(min_)specialization`)
 - rust-lang#119971 (Use `zip_eq` to enforce that things being zipped have equal sizes)
 - rust-lang#119974 (Minor `trimmed_def_paths` improvements)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 15, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#119818 (Silence some follow-up errors [3/x])
 - rust-lang#119870 (std: Doc blocking behavior of LazyLock)
 - rust-lang#119897 (`OutputTypeParameterMismatch` -> `SignatureMismatch`)
 - rust-lang#119963 (Fix `allow_internal_unstable` for `(min_)specialization`)
 - rust-lang#119971 (Use `zip_eq` to enforce that things being zipped have equal sizes)
 - rust-lang#119974 (Minor `trimmed_def_paths` improvements)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6f2670d into rust-lang:master Jan 15, 2024
11 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Jan 15, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 15, 2024
Rollup merge of rust-lang#119870 - behnam-oneschema:lazylock-blocking-1, r=tgross35,ChrisDenton

std: Doc blocking behavior of LazyLock

Adding notes about blocking behavior of calls that can block the current thread, similar to those on https://doc.rust-lang.org/std/sync/struct.OnceLock.html

I'm not sure if the "This method never blocks." counterparts would be desired. If so, can add those, as well.
@behnam-oneschema behnam-oneschema deleted the lazylock-blocking-1 branch January 16, 2024 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants