about summary refs log tree commit diff
path: root/library/std/src/sync/lazy_lock.rs
AgeCommit message (Collapse)AuthorLines
2025-08-22modify `LazyLock` poison panic messageConnor Tsui-3/+6
Fixes an issue where if the underlying `Once` panics because it is poisoned, the panic displays the wrong message. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-03add poisoning documentation to `LazyLock`Connor Tsui-2/+58
2025-07-01Update version placeholdersJosh Stone-1/+1
2025-05-10Rollup merge of #129334 - ChayimFriedman2:more-lazy-methods, r=AmanieuMatthias Krüger-1/+9
Implement (part of) ACP 429: add `DerefMut` to `Lazy[Cell/Lock]` `DerefMut` is instantly stable, as a trait impl. That means this needs an FCP. ``@rustbot`` label +needs-fcp https://github.com/rust-lang/libs-team/issues/429
2025-01-26Move std::sync unit tests to integration testsbjorn3-3/+0
This removes two minor OnceLock tests which test private methods. The rest of the tests should be more than enough to catch mistakes in those private methods. Also makes ReentrantLock::try_lock public. And finally it makes the mpmc tests actually run.
2025-01-15Clarify note in `std::sync::LazyLock` exampleAeon-1/+1
2025-01-02Move some things to `std::sync::poison` and reexport them in `std::sync`Pavel Grigorenko-1/+2
2024-11-16Add `DerefMut` for `Lazy[Cell/Lock]` that delegates to the unstable ↵Chayim Refael Friedman-1/+9
`force_mut()`
2024-11-07fix lazylock commentXinye-2/+2
Signed-off-by: Xinye <xinye.tao@metabit-trading.com>
2024-09-18Rollup merge of #130476 - workingjubilee:more-lazy-methods-take-2, r=AmanieuJubilee-6/+111
Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut` Tracking issue for `lazy_get`: https://github.com/rust-lang/rust/issues/129333
2024-09-18library: Call it really_init_mut to avoid name collisionsJubilee Young-2/+2
2024-09-18library: Destabilize Lazy{Cell,Lock}::{force,deref}_mutJubilee Young-14/+3
2024-09-17Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut`Chayim Refael Friedman-7/+123
In the implementation of `force_mut`, I chose performance over safety. For `LazyLock` this isn't really a choice; the code has to be unsafe. But for `LazyCell`, we can have a full-safe implementation, but it will be a bit less performant, so I went with the unsafe approach.
2024-09-16fix: Remove duplicate `LazyLock` example.Andrew Lilley Brinker-2/+0
The top-level docs for `LazyLock` included two lines of code, each with an accompanying comment, that were identical and with nearly- identical comments. This looks like an oversight from a past edit which was perhaps trying to rewrite an existing example but ended up duplicating rather than replacing, though I haven't gone back through the Git history to check. This commit removes what I personally think is the less-clear of the two examples. Signed-off-by: Andrew Lilley Brinker <alilleybrinker@gmail.com>
2024-07-29Reformat `use` declarations.Nicholas Nethercote-2/+1
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Fix doc nitsJohn Arundel-1/+1
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-07-11Rename `lazy_cell_consume` to `lazy_cell_into_inner`Trevor Gross-2/+2
Name this something that is less confusable with an atomic consume API for `{Lazy,Once}Lock`.
2024-06-11replace version placeholderPietro Albini-11/+11
2024-06-02Move first OnceLock example to LazyLockJubilee Young-22/+14
This example is spiritually an example of LazyLock, as it computes a variable at runtime but accepts no inputs into that process. It is also slightly simpler and thus easier to understand. Change it to an even-more concise version and move it to LazyLock. The example now editorializes slightly more. This may be unnecessary, but it can be educational for the reader.
2024-05-28update tracking issue for lazy_cell_consumeTrevor Spiteri-1/+1
2024-02-20Stabilize `LazyCell` and `LazyLock` (`lazy_cell`)Peter Jaszkowiak-18/+23
2024-01-14std: Doc blocking behavior of LazyLock methodsBehnam Esfahbod-6/+15
2023-07-31Rollup merge of #109318 - joboet:better_fmt_placeholder, r=dtolnayMatthias Krüger-3/+5
Make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent with `Mutex` and `RwLock` `Mutex` prints `<locked>` as a field value when its inner value cannot be accessed, but the lazy types print a fixed string like "`OnceCell(Uninit)`". This could cause confusion if the inner type is a unit type named `Uninit` and does not respect the pretty-printing flag. With this change, the format message is now "`OnceCell(<uninit>)`", consistent with `Mutex`.
2023-07-30Rollup merge of #109075 - joboet:lazylock_backtrace, r=workingjubileeJubilee-0/+9
Use `LazyLock` to lazily resolve backtraces By using TAIT to name the initializing closure, `LazyLock` can be used to replace the current `LazilyResolvedCapture`.
2023-07-25docs(LazyLock): add example pass local LazyLock variable to structDragonBillow-0/+20
Signed-off-by: DragonBillow <DragonBillow@outlook.com>
2023-04-27std: use `LazyLock` to lazily resolve backtracesjoboet-0/+9
2023-04-19std: make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent ↵joboet-3/+5
with `Mutex` and `RwLock` `Mutex` prints `<locked>` as a field value when its inner value cannot be accessed, but the lazy types print a fixed string like "`OnceCell(Uninit)`". This could cause confusion if the inner type is a unit type named `Uninit` and does not respect the pretty-printing flag. With this change, the format message is now "`OnceCell(<uninit>)`", consistent with `Mutex`.
2023-04-14Add Lazy{Cell,Lock}::into_innerAlex Saveau-1/+37
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-03-29Stabilize a portion of 'once_cell'Trevor Gross-12/+12
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-01-27std: add safety comment in `LazyLock::get`joboet-1/+8
2023-01-27std: fix `Debug` implementation on `LazyLock`joboet-8/+5
2023-01-26std: optimize `LazyLock` sizejoboet-16/+66
2022-12-30Auto merge of #105651 - tgross35:once-cell-inline, r=m-ou-sebors-0/+5
Add #[inline] markers to once_cell methods Added inline markers to all simple methods under the `once_cell` feature. Relates to #74465 and #105587 This should not block #105587
2022-12-27Rollup merge of #103718 - matklad:infer-lazy, r=dtolnayMichael Goulet-4/+1
More inference-friendly API for lazy The signature for new was ``` fn new<F>(f: F) -> Lazy<T, F> ``` Notably, with `F` unconstrained, `T` can be literally anything, and just `let _ = Lazy::new(|| 92)` would not typecheck. This historiacally was a necessity -- `new` is a `const` function, it couldn't have any bounds. Today though, we can move `new` under the `F: FnOnce() -> T` bound, which gives the compiler enough data to infer the type of T from closure.
2022-12-13Add #[inline] marker to OnceCell/LazyCell/OnceLock/LazyLockTrevor Gross-0/+5
2022-11-17Properly link `{Once,Lazy}{Cell,Lock}` in docsMaybe Waffle-1/+3
2022-10-29More inference-friendly API for lazyAleksey Kladov-4/+1
The signature for new was ``` fn new<F>(f: F) -> Lazy<T, F> ``` Notably, with `F` unconstrained, `T` can be literally anything, and just `let _ = Lazy::new(|| 92)` would not typecheck. This historiacally was a necessity -- `new` is a `const` function, it couldn't have any bounds. Today though, we can move `new` under the `F: FnOnce() -> T` bound, which gives the compiler enough data to infer the type of T from closure.
2022-06-16Move/rename `lazy::Sync{OnceCell,Lazy}` to `sync::{Once,Lazy}Lock`Maybe Waffle-0/+121