about summary refs log tree commit diff
path: root/src/libstd/thread/local.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-747/+0
2020-07-12rename fast_thread_local -> thread_local_dtor; thread_local -> thread_local_keyRalf Jung-2/+2
2020-04-17Fix unused results from mem::replaceJosh Stone-1/+1
2020-03-30Add inline attributes for functions used in the query systemJohn Kåre Alsaker-0/+1
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-3/+3
2019-11-29Format libstd with rustfmtDavid Tolnay-54/+49
This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libstd. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference
2019-11-06Update local.rs3442853561-2/+2
Removed parameters not used in the macro
2019-10-22Apply clippy::single_match suggestionMateusz Mikuła-3/+2
2019-09-16updated the panic message wordingTomas Tauber-1/+1
2019-09-15Made a thread local storage panic message more explanatoryTomas Tauber-2/+2
(TLS is usually understood as Transport Layer Security outside rust-std internals)
2019-08-04Add #[stable] to Error implStjepan Glavina-0/+1
2019-06-20Add a few trait impls for AccessErrorStjepan Glavina-0/+4
2019-05-15fix wasm unused import in thread local implementationtyler-1/+0
2019-05-15llvm makes good inlining choices with only the #[cold] attributetyler-19/+15
2019-05-15remove trailing whitespacetyler-1/+1
2019-05-15cold was necessary on try_initialize_nodrop to get more straight line asmtyler-0/+1
2019-05-15- remove unnecessary inlinestyler-21/+18
- add comment explaining that the fast::Key data structure was carefully constructed for fast access on OSX - remove inline(never) from the initializer for types where `needs_drop::<T>()` is false
2019-05-15add #[allow(unused)]tyler-0/+1
2019-05-15restructure thread_local! for better codegen (especially on macos)tyler-97/+188
2019-05-15Revert "ensure fast thread local lookups occur once per access on macos"tyler-6/+5
This reverts commit d252f3b77f3b7d4cd59620588f9d026633c05816.
2019-05-15ensure fast thread local lookups occur once per access on macostyler-5/+6
2019-05-15remove dead code: requires_move_before_droptyler-12/+3
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-6/+6
2019-03-25SGX target: fix std unit testsJethro Beekman-3/+3
2019-03-03race condition in thread local storage examplebenaryorg-1/+4
The example had a potential race condition that would still pass the test. If the thread which was supposed to modify it's own thread local was slower than the instruction to modify in the main thread, then the test would pass even in case of a failure. This is would be minor if the child thread was waited for since it check using an `assert_eq` for the same thing, but vice versa. However, if the `assert_eq` failed this would trigger a panic, which is not at all caught by the example since the thread is not waited on. Signed-off-by: benaryorg <binary@benary.org>
2019-03-02Bootstrap compiler update for 1.35 releaseMark Rousskov-6/+2
2019-02-28libstd => 2018Taiki Endo-23/+23
2019-02-11Require a list of features to allow in `allow_internal_unstable`Oliver Scherer-2/+6
2019-01-15OSX: fix #57534 registering thread dtors while running thread dtorstyler-7/+1
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-1/+1
2018-11-06Rollup merge of #55597 - alexcrichton:thread-local-inner, r=KodrAuskennytm-4/+4
std: Enable usage of `thread_local!` through imports The `thread_local!` macro delegated to an internal macro but it didn't do so in a macros-and-the-module-system compatible fashion, meaning if a `#![no_std]` crate imported `std` and tried to use `thread_local!` it would fail due to missing a lookup of an internal macro. This commit switches the macro to instead use `$crate` to invoke other macros, ensuring that it'll work when `thread_local!` is imported alone.
2018-11-01std: Enable usage of `thread_local!` through importsAlex Crichton-4/+4
The `thread_local!` macro delegated to an internal macro but it didn't do so in a macros-and-the-module-system compatible fashion, meaning if a `#![no_std]` crate imported `std` and tried to use `thread_local!` it would fail due to missing a lookup of an internal macro. This commit switches the macro to instead use `$crate` to invoke other macros, ensuring that it'll work when `thread_local!` is imported alone.
2018-11-01std: Improve codegen size of accessing TLSAlex Crichton-1/+10
Some code in the TLS implementation in libstd stores `Some(val)` into an `&mut Option<T>` (effectively) and then pulls out `&T`, but it currently uses `.unwrap()` which can codegen into a panic even though it can never panic. With sufficient optimizations enabled (like LTO) the compiler can see through this but this commit helps it along in normal mode (`--release` with Cargo by default) to avoid codegen'ing the panic path. This ends up improving the optimized codegen on wasm by ensuring that a call to panic pulling in more file size doesn't stick around.
2018-10-11std: Implement TLS for wasm32-unknown-unknownAlex Crichton-4/+10
This adds an implementation of thread local storage for the `wasm32-unknown-unknown` target when the `atomics` feature is implemented. This, however, comes with a notable caveat of that it requires a new feature of the standard library, `wasm-bindgen-threads`, to be enabled. Thread local storage for wasm (when `atomics` are enabled and there's actually more than one thread) is powered by the assumption that an external entity can fill in some information for us. It's not currently clear who will fill in this information nor whose responsibility it should be long-term. In the meantime there's a strategy being gamed out in the `wasm-bindgen` project specifically, and the hope is that we can continue to test and iterate on the standard library without committing to a particular strategy yet. As to the details of `wasm-bindgen`'s strategy, LLVM doesn't currently have the ability to emit custom `global` values (thread locals in a `WebAssembly.Module`) so we leverage the `wasm-bindgen` CLI tool to do it for us. To that end we have a few intrinsics, assuming two global values: * `__wbindgen_current_id` - gets the current thread id as a 32-bit integer. It's `wasm-bindgen`'s responsibility to initialize this per-thread and then inform libstd of the id. Currently `wasm-bindgen` performs this initialization as part of the `start` function. * `__wbindgen_tcb_{get,set}` - in addition to a thread id it's assumed that there's a global available for simply storing a pointer's worth of information (a thread control block, which currently only contains thread local storage). This would ideally be a native `global` injected by LLVM, but we don't have a great way to support that right now. To reiterate, this is all intended to be unstable and purely intended for testing out Rust on the web with threads. The story is very likely to change in the future and we want to make sure that we're able to do that!
2018-06-27Fix the error reference for LocalKey::try_withMichal 'vorner' Vaner-1/+1
2018-04-13std: Minimize size of panicking on wasmAlex Crichton-2/+39
This commit applies a few code size optimizations for the wasm target to the standard library, namely around panics. We notably know that in most configurations it's impossible for us to print anything in wasm32-unknown-unknown so we can skip larger portions of panicking that are otherwise simply informative. This allows us to get quite a nice size reduction. Finally we can also tweak where the allocation happens for the `Box<Any>` that we panic with. By only allocating once unwinding starts we can reduce the size of a panicking wasm module from 44k to 350 bytes.
2018-03-01Fix a bug introduced in previous commitStjepan Glavina-6/+3
2018-02-28Remove thread_local_stateStjepan Glavina-104/+7
2018-02-28Stabilize LocalKey::try_withStjepan Glavina-13/+15
2017-10-26Bump to 1.23 and update bootstrapAlex Crichton-5/+0
This commit updates the bootstrap compiler, bumps the version to 1.23, updates Cargo, updates books, and updates crates.io dependencies
2017-10-17Docs: a LocalKey might start in the Valid stateStjepan Glavina-1/+4
2017-09-07std::thread::LocalKey: Document limitation with initializersJoshua Liebow-Feeser-0/+4
2017-09-04Make the LocalKey facade of thread_local! inlineable cross-crate.Eduard-Mihai Burtescu-3/+13
2017-08-31Update bootstrap compilerAlex Crichton-4/+1
This commit updates the bootstrap compiler and clears out a number of #[cfg(stage0)] annotations and related business
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-2/+2
Like #43008 (f668999), but _much more aggressive_.
2017-08-12Check #[thread_local] statics correctly in the compiler.Eduard-Mihai Burtescu-31/+31
2017-07-25Bump master to 1.21.0Alex Crichton-67/+0
This commit bumps the master branch's version to 1.21.0 and also updates the bootstrap compiler from the freshly minted beta release.
2017-07-15Auto merge of #43185 - durka:thread-local-pub-restricted, r=alexcrichtonbors-1/+57
support pub(restricted) in thread_local! (round 2) Resurrected #40984 now that the issue blocking it was fixed. Original description: `pub(restricted)` was stabilized in #40556 so let's go! Here is a [playground](https://play.rust-lang.org/?gist=f55f32f164a6ed18c219fec8f8293b98&version=nightly&backtrace=1). I changed the interface of `__thread_local_inner!`, which is supposedly unstable but this is not checked for macros (#34097 cc @petrochenkov @jseyfried), so this may be an issue.
2017-07-12Use try_with for with implementationLee Bousfield-9/+2