about summary refs log tree commit diff
path: root/src/libstd/sync/once.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-690/+0
2020-07-17appease tidyAshley Mannix-1/+4
2020-07-17remove inlined lazy::Waiter in favor of sync::OnceAshley Mannix-4/+14
2020-05-24Fix typo in doc comment.Eitan Mosenkis-1/+1
call_one_force -> call_once_force
2020-04-26Use Cell::take in a couple placesThinkChaos-1/+1
2020-03-15Fix "since" field for `Once::is_complete`'s `#[stable]` attributeLukas Kalbertodt-1/+1
It was accidentally merged with the wrong version.
2020-02-07Stabilize Once::is_completedMichael Bradshaw-6/+5
2019-12-18Propagate cfg bootstrapMark Rousskov-1/+1
2019-12-13Require stable/unstable annotations for the constness of all stable ↵Oliver Scherer-0/+1
functions with a `const` modifier
2019-11-09Run rustfmt on libstd/sync/once.rsPaul Dicker-32/+29
2019-11-05Don't mutate node.nextPaul Dicker-36/+34
2019-10-25Mention park guaranteePaul Dicker-0/+4
2019-10-24Always align Waiter to 4 bytesPaul Dicker-0/+1
2019-10-24Use more precise atomic orderingsPaul Dicker-12/+41
2019-10-24In Waiter use interior mutability for threadPaul Dicker-9/+19
2019-10-24Reduce the amount of comments in call_innerPaul Dicker-19/+6
2019-10-24Move thread parking to a seperate functionPaul Dicker-38/+42
2019-10-24Turn Finish into WaiterQueuePaul Dicker-23/+21
2019-10-23Don't mutate waiter nodesPaul Dicker-9/+9
2019-10-23Simplify loop conditions in RUNNING and add commentsPaul Dicker-17/+29
2019-10-23Rename state to state_and_queuePaul Dicker-28/+29
2019-10-16Don't recommend ONCE_INIT in std::sync::Onceboyned//Kampfkarren-3/+2
ONCE_INIT is deprecated, and so suggesting it as not only being on par with, but before `Once::new` is a bad idea.
2019-06-12Deprecate ONCE_INITSteven Fackler-0/+5
Once::new() has been a stable const fn for a while now. Closes #61746
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-1/+1
2019-02-28libstd => 2018Taiki Endo-8/+8
2019-02-20Rollup merge of #58553 - scottmcm:more-ihle, r=Centrilkennytm-1/+1
Use more impl header lifetime elision Inspired by seeing explicit lifetimes on these two: - https://doc.rust-lang.org/nightly/std/slice/struct.Iter.html#impl-FusedIterator - https://doc.rust-lang.org/nightly/std/primitive.u32.html#impl-Not And a follow-up to https://github.com/rust-lang/rust/pull/54687, that started using IHLE in libcore. Most of the changes in here fall into two big categories: - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop`, `Debug`, and `Clone`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations [where the flipped one cannot elide the lifetime](https://internals.rust-lang.org/t/impl-type-parameter-aliases/9403/2?u=scottmcm). I also removed two lifetimes that turned out to be completely unused; see https://github.com/rust-lang/rust/issues/41960#issuecomment-464557423
2019-02-17Use more impl header lifetime elisionScott McMurray-1/+1
There are two big categories of changes in here - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop` & `Debug`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations where the flipped one cannot elide the lifetime.
2019-02-10libs: doc commentsAlexander Regueiro-3/+3
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-2/+2
2018-10-23fix typos in various placesMatthias Krüger-2/+2
2018-10-07Fix tracking issue for Once::is_completedSimon Sapin-1/+1
2018-09-29Fix Once perf regressionAleksey Kladov-0/+1
Because `call_once` is generic, but `is_completed` is not, we need `#[inline]` annotation to allow LLVM to inline `is_completed` into `call_once` in downstream crates.
2018-09-05Auto merge of #53027 - matklad:once_is_completed, r=alexcrichtonbors-14/+59
Allow to check if sync::Once is already initialized Hi! I propose to expose a way to check if a `Once` instance is initialized. I need it in `once_cell`. `OnceCell` is effetively a pair of `(Once, UnsafeCell<Option<T>>)`, which can set the `T` only once. Because I can't check if `Once` is initialized, I am forced to add an indirection and check the value of ptr instead: https://github.com/matklad/once_cell/blob/8127a81976c3f2f4c0860562c3f14647ebc025c0/src/lib.rs#L423-L429 https://github.com/matklad/once_cell/blob/8127a81976c3f2f4c0860562c3f14647ebc025c0/src/lib.rs#L457-L461 The `parking_lot`'s version of `Once` exposes the state as an enum: https://docs.rs/parking_lot/0.6.3/parking_lot/struct.Once.html#method.state. I suggest, for now, just to add a simple `bool` function: this fits my use-case perfectly, exposes less implementation details, and is forward-compatible with more fine-grained state checking.
2018-08-19Fix typos found by codespell.Matthias Krüger-1/+1
2018-08-09Reduce code duplication in OnceAleksey Kladov-14/+18
2018-08-06Remove references to `StaticMutex` which got removed a while agoRalf Jung-6/+4
2018-08-03Fix trailnig WSAleksey Kladov-1/+1
2018-08-03Allow to check if sync::Once is initializedAleksey Kladov-0/+41
2018-08-03Specify reentrancy gurantees of `Once::call_once`Aleksey Kladov-0/+4
2018-07-25Merge remote-tracking branches 'ljedrz/dyn_libcore', 'ljedrz/dyn_libstd' and ↵Tatsuyuki Ishi-1/+1
'ljedrz/dyn_libterm' into dyn-rollup
2018-07-17sync::Once: Use Acquire on the hot path, and explain why we don't use it ↵Ralf Jung-2/+10
elsewhere
2018-07-10remove sync::Once::call_once 'staticChristopher Durham-6/+6
- [std: Rewrite the `sync` modulehttps://github.com/rust-lang/rust/commit/71d4e77db8ad4b6d821da7e5d5300134ac95974e) (Nov 2014) ```diff - pub fn doit(&self, f: ||) { + pub fn doit(&'static self, f: ||) { ``` > ```text > The second layer is the layer provided by `std::sync` which is intended to be > the thinnest possible layer on top of `sys_common` which is entirely safe to > use. There are a few concerns which need to be addressed when making these > system primitives safe: > > * Once used, the OS primitives can never be **moved**. This means that they > essentially need to have a stable address. The static primitives use > `&'static self` to enforce this, and the non-static primitives all use a > `Box` to provide this guarantee. > ``` The author of this diff is @alexcrichton. `sync::Once` contains only a pointer to (privately hidden) `Waiter`s, which are all stack-allocated. The `'static` bound to `sync::Once` is thus unnecessary to guarantee that any OS primitives are non-relocatable. See https://internals.rust-lang.org/t/sync-once-per-instance/7918 for more context.
2018-07-10Deny bare trait objects in `src/libstd`.ljedrz-1/+1
2018-05-24Update the `Once` docs to use `Once::new`Tobias Bucher-10/+10
2018-05-24Add `Once::new` as a way of constructing a `Once`Tobias Bucher-1/+2
2017-11-26Stabilize const-calling existing const-fns in stdSimon Sapin-1/+0
Fixes #46038
2017-10-26Bump to 1.23 and update bootstrapAlex Crichton-1/+1
This commit updates the bootstrap compiler, bumps the version to 1.23, updates Cargo, updates books, and updates crates.io dependencies
2017-10-22Improve docs around `Once::call_once_force` and `OnceState`.Corey Farwell-13/+81
2017-09-16change #![feature(const_fn)] to specific gatesAlex Burka-0/+1