about summary refs log tree commit diff
path: root/src/libstd/sync/once.rs
AgeCommit message (Collapse)AuthorLines
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
2017-08-15Fix typos & us spellingsFourchaux-1/+1
2017-08-01Fixed all unnecessary muts in language coreIsaac van Bakel-1/+1
2017-03-29Adding linking for Once docs #29377projektir-8/+29
2017-02-15Fix wording in LocalKey documentationStjepan Glavina-1/+1
2017-01-29Fix a few impl stability attributesOliver Middleton-1/+1
The versions show up in rustdoc.
2016-12-18Implement `fmt::Debug` for all structures in libstd.Corey Farwell-0/+9
Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-10-14Rename static mut to upper caseAleksey Kladov-7/+7
2016-09-30Ignore various entire test modules on emscriptenBrian Anderson-3/+1
2016-09-30Ignore lots and lots of std tests on emscriptenBrian Anderson-0/+2
2016-08-24Use `#[prelude_import]` in `libstd`.Jeffrey Seyfried-2/+0
2016-07-12Use `ptr::{null, null_mut}` instead of `0 as *{const, mut}`Tobias Bucher-1/+2
2016-05-20update tracking issue for once_poisonAlex Burka-3/+3
The tracking issue for once_poison was noted as #31688 which was closed, so it now points to the new #33577.
2016-05-11Fix typo in std::sync::Once documentationAmanieu d'Antras-1/+0
2016-04-11std: Stabilize APIs for the 1.9 releaseAlex Crichton-3/+3
This commit applies all stabilizations, renamings, and deprecations that the library team has decided on for the upcoming 1.9 release. All tracking issues have gone through a cycle-long "final comment period" and the specific APIs stabilized/deprecated are: Stable * `std::panic` * `std::panic::catch_unwind` (renamed from `recover`) * `std::panic::resume_unwind` (renamed from `propagate`) * `std::panic::AssertUnwindSafe` (renamed from `AssertRecoverSafe`) * `std::panic::UnwindSafe` (renamed from `RecoverSafe`) * `str::is_char_boundary` * `<*const T>::as_ref` * `<*mut T>::as_ref` * `<*mut T>::as_mut` * `AsciiExt::make_ascii_uppercase` * `AsciiExt::make_ascii_lowercase` * `char::decode_utf16` * `char::DecodeUtf16` * `char::DecodeUtf16Error` * `char::DecodeUtf16Error::unpaired_surrogate` * `BTreeSet::take` * `BTreeSet::replace` * `BTreeSet::get` * `HashSet::take` * `HashSet::replace` * `HashSet::get` * `OsString::with_capacity` * `OsString::clear` * `OsString::capacity` * `OsString::reserve` * `OsString::reserve_exact` * `OsStr::is_empty` * `OsStr::len` * `std::os::unix::thread` * `RawPthread` * `JoinHandleExt` * `JoinHandleExt::as_pthread_t` * `JoinHandleExt::into_pthread_t` * `HashSet::hasher` * `HashMap::hasher` * `CommandExt::exec` * `File::try_clone` * `SocketAddr::set_ip` * `SocketAddr::set_port` * `SocketAddrV4::set_ip` * `SocketAddrV4::set_port` * `SocketAddrV6::set_ip` * `SocketAddrV6::set_port` * `SocketAddrV6::set_flowinfo` * `SocketAddrV6::set_scope_id` * `<[T]>::copy_from_slice` * `ptr::read_volatile` * `ptr::write_volatile` * The `#[deprecated]` attribute * `OpenOptions::create_new` Deprecated * `std::raw::Slice` - use raw parts of `slice` module instead * `std::raw::Repr` - use raw parts of `slice` module instead * `str::char_range_at` - use slicing plus `chars()` plus `len_utf8` * `str::char_range_at_reverse` - use slicing plus `chars().rev()` plus `len_utf8` * `str::char_at` - use slicing plus `chars()` * `str::char_at_reverse` - use slicing plus `chars().rev()` * `str::slice_shift_char` - use `chars()` plus `Chars::as_str` * `CommandExt::session_leader` - use `before_exec` instead. Closes #27719 cc #27751 (deprecating the `Slice` bits) Closes #27754 Closes #27780 Closes #27809 Closes #27811 Closes #27830 Closes #28050 Closes #29453 Closes #29791 Closes #29935 Closes #30014 Closes #30752 Closes #31262 cc #31398 (still need to deal with `before_exec`) Closes #31405 Closes #31572 Closes #31755 Closes #31756
2016-03-26std: Rewrite Once with poisoningAlex Crichton-56/+363
This commit rewrites the `std::sync::Once` primitive with poisoning in mind in light of #31688. Currently a panic in the initialization closure will cause future initialization closures to run, but the purpose of a Once is usually to initialize some global state so it's highly likely that the global state is corrupt if a panic happened. The same strategy of a mutex is taken where a panic is propagated by default. A new API, `call_once_force`, was added to subvert panics like is available on Mutex as well (for when panicking is handled internally). Adding this support was a significant enough change to the implementation that it was just completely rewritten from scratch, primarily to avoid using a `StaticMutex` which needs to have `destroy()` called on it at some point (a pain to do). Closes #31688
2015-08-11Register new snapshotsAlex Crichton-3/+0
* Lots of core prelude imports removed * Makefile support for MSVC env vars and Rust crates removed * Makefile support for morestack removed
2015-08-03syntax: Implement #![no_core]Alex Crichton-0/+1
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: https://github.com/rust-lang/rfcs/pull/1184
2015-06-17std: Stabilize the `once_new` featureAlex Crichton-1/+1
This function follows the well-established "constructor" pattern and the initialization constant will likely be deprecated in favor of it once `const_fn` is stabilized.
2015-06-17std: Split the `std_misc` featureAlex Crichton-1/+1
2015-05-27Use `const fn` to abstract away the contents of UnsafeCell & friends.Eduard Burtescu-10/+16
2015-05-09Squeeze the last bits of `task`s in documentation in favor of `thread`Barosl Lee-2/+2
An automated script was run against the `.rs` and `.md` files, subsituting every occurrence of `task` with `thread`. In the `.rs` files, only the texts in the comment blocks were affected.
2015-04-28Clarify Once::call_once memory ordering guarantees in docsinrustwetrust-1/+5
2015-04-24Change name of unit test sub-module to "tests".Johannes Oertel-1/+1
Changes the style guidelines regarding unit tests to recommend using a sub-module named "tests" instead of "test" for unit tests as "test" might clash with imports of libtest.