diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2021-03-23 11:04:29 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2021-04-16 09:21:38 -0700 |
| commit | c6eea222a9cafeeeedfa1767232328710b350447 (patch) | |
| tree | 445d5ae2cf15dca79fe4ac1611e83aedccb08ac6 /compiler/rustc_codegen_llvm/src/llvm_util.rs | |
| parent | f1ca558db189690a9774713306c94550681ac590 (diff) | |
| download | rust-c6eea222a9cafeeeedfa1767232328710b350447.tar.gz rust-c6eea222a9cafeeeedfa1767232328710b350447.zip | |
std: Add a variant of thread locals with const init
This commit adds a variant of the `thread_local!` macro as a new `thread_local_const_init!` macro which requires that the initialization expression is constant (e.g. could be stuck into a `const` if so desired). This form of thread local allows for a more efficient implementation of `LocalKey::with` both if the value has a destructor and if it doesn't. If the value doesn't have a destructor then `with` should desugar to exactly as-if you use `#[thread_local]` given sufficient inlining. The purpose of this new form of thread locals is to precisely be equivalent to `#[thread_local]` on platforms where possible for values which fit the bill (those without destructors). This should help close the gap in performance between `thread_local!`, which is safe, relative to `#[thread_local]`, which is not easy to use in a portable fashion.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm_util.rs')
0 files changed, 0 insertions, 0 deletions
