1
Fork 0
Commit graph

88 commits

Author SHA1 Message Date
Paul Dicker
c11a44ab6c Use more precise atomic orderings 2019-10-24 17:57:07 +02:00
Paul Dicker
88c70edef6 In Waiter use interior mutability for thread 2019-10-24 17:57:05 +02:00
Paul Dicker
4b8da9ccd5 Reduce the amount of comments in call_inner 2019-10-24 17:28:08 +02:00
Paul Dicker
2e8eb5f33d Move thread parking to a seperate function 2019-10-24 17:28:08 +02:00
Paul Dicker
fbc242f1ef Turn Finish into WaiterQueue 2019-10-24 17:28:04 +02:00
Paul Dicker
1479c22a39 Don't mutate waiter nodes 2019-10-23 16:38:50 +02:00
Paul Dicker
7f1e166899 Simplify loop conditions in RUNNING and add comments 2019-10-23 12:09:54 +02:00
Paul Dicker
2ab812c181 Rename state to state_and_queue 2019-10-23 12:09:53 +02:00
boyned//Kampfkarren
247df6e134
Don't recommend ONCE_INIT in std::sync::Once
ONCE_INIT is deprecated, and so suggesting it as not only being on par with, but before `Once::new` is a bad idea.
2019-10-16 00:06:01 -07:00
Steven Fackler
72e99f57c5 Deprecate ONCE_INIT
Once::new() has been a stable const fn for a while now.

Closes #61746
2019-06-12 21:32:51 -07:00
Mazdak Farrokhzad
379c380a60 libstd: deny(elided_lifetimes_in_paths) 2019-03-31 12:56:51 +02:00
Taiki Endo
93b6d9e086 libstd => 2018 2019-02-28 04:06:15 +09:00
kennytm
e3a8f7db47
Rollup merge of #58553 - scottmcm:more-ihle, r=Centril
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-20 11:59:10 +08:00
Scott McMurray
3bea2ca49d Use more impl header lifetime elision
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-17 19:42:36 -08:00
Alexander Regueiro
99ed06eb88 libs: doc comments 2019-02-10 23:57:25 +00:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Alexander Regueiro
ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
Matthias Krüger
4972beaf65 fix typos in various places 2018-10-23 15:56:25 +02:00
Simon Sapin
9a9894a8f1
Fix tracking issue for Once::is_completed 2018-10-07 12:00:41 +02:00
Aleksey Kladov
f8e9d2f0ec Fix Once perf regression
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-29 11:07:48 +03:00
bors
f68b7cc598 Auto merge of #53027 - matklad:once_is_completed, r=alexcrichton
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:

8127a81976/src/lib.rs (L423-L429)

8127a81976/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-09-05 00:37:03 +00:00
Matthias Krüger
71120ef1e5 Fix typos found by codespell. 2018-08-19 17:41:28 +02:00
Aleksey Kladov
e1bd0e7b4e Reduce code duplication in Once 2018-08-09 20:50:43 +03:00
Ralf Jung
a92b5cc916 Remove references to StaticMutex which got removed a while ago 2018-08-06 12:34:00 +02:00
Aleksey Kladov
a2f9aaf7a3
Fix trailnig WS 2018-08-03 16:50:30 +03:00
Aleksey Kladov
6aba6f9184 Allow to check if sync::Once is initialized 2018-08-03 15:49:23 +03:00
Aleksey Kladov
94de821002
Specify reentrancy gurantees of Once::call_once 2018-08-03 14:18:06 +03:00
Tatsuyuki Ishi
4f1d4e4db6 Merge remote-tracking branches 'ljedrz/dyn_libcore', 'ljedrz/dyn_libstd' and 'ljedrz/dyn_libterm' into dyn-rollup 2018-07-25 10:25:02 +09:00
Ralf Jung
3e1254d956 sync::Once: Use Acquire on the hot path, and explain why we don't use it elsewhere 2018-07-17 20:51:31 +02:00
Christopher Durham
0f3f292b4c
remove sync::Once::call_once 'static
- [std: Rewrite the `sync` module71d4e77db8) (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-10 22:47:59 -04:00
ljedrz
560d8079ec Deny bare trait objects in src/libstd. 2018-07-10 20:35:36 +02:00
Tobias Bucher
2a900e2b84 Update the Once docs to use Once::new 2018-05-24 14:09:42 +02:00
Tobias Bucher
1c2abda671 Add Once::new as a way of constructing a Once 2018-05-24 14:08:47 +02:00
Simon Sapin
6c5f53e65e Stabilize const-calling existing const-fns in std
Fixes #46038
2017-11-26 23:43:44 +01:00
Alex Crichton
ca18537197 Bump to 1.23 and update bootstrap
This commit updates the bootstrap compiler, bumps the version to 1.23, updates
Cargo, updates books, and updates crates.io dependencies
2017-10-26 13:59:18 -07:00
Corey Farwell
aae94c7368 Improve docs around Once::call_once_force and OnceState. 2017-10-22 10:25:31 -04:00
Alex Burka
681e5da61e change #![feature(const_fn)] to specific gates 2017-09-16 15:53:02 +00:00
Fourchaux
c7104be1a3 Fix typos & us spellings 2017-08-15 21:56:30 +02:00
Isaac van Bakel
400075d9d9 Fixed all unnecessary muts in language core 2017-08-01 23:01:24 +01:00
projektir
3207657d12 Adding linking for Once docs #29377 2017-03-29 00:21:55 -04:00
Stjepan Glavina
1fbbe79bcb Fix wording in LocalKey documentation 2017-02-15 23:31:51 +01:00
Oliver Middleton
9128f6100c Fix a few impl stability attributes
The versions show up in rustdoc.
2017-01-29 13:31:47 +00:00
Corey Farwell
86fc63e62d Implement fmt::Debug for all structures in libstd.
Part of https://github.com/rust-lang/rust/issues/31869.

Also turn on the `missing_debug_implementations` lint at the crate
level.
2016-12-18 14:55:14 -08:00
Aleksey Kladov
72399f2db7 Rename static mut to upper case 2016-10-14 17:21:11 +03:00
Brian Anderson
096670ca41 Ignore various entire test modules on emscripten 2016-09-30 14:02:56 -07:00
Brian Anderson
9c4a01ee9e Ignore lots and lots of std tests on emscripten 2016-09-30 14:02:48 -07:00
Jeffrey Seyfried
9a2c8783d9 Use #[prelude_import] in libstd. 2016-08-24 22:12:48 +00:00
Tobias Bucher
81e95c18b7 Use ptr::{null, null_mut} instead of 0 as *{const, mut} 2016-07-12 10:40:40 +02:00
Alex Burka
b9d1e76252 update tracking issue for once_poison
The tracking issue for once_poison was noted as #31688 which was closed, so it now points to the new #33577.
2016-05-20 20:30:08 -04:00
Amanieu d'Antras
5cbfa1285d Fix typo in std::sync::Once documentation 2016-05-11 20:42:26 +01:00