Add fast-path for accessing the current thread id#143069
Add fast-path for accessing the current thread id#143069bors merged 1 commit intorust-lang:masterfrom
Conversation
|
r? libs-api |
|
☔ The latest upstream changes (presumably #115746) made this pull request unmergeable. Please resolve the merge conflicts. |
Could you submit one anyway? It's the easiest way to get something on the radar, and it should be trivial. |
|
r? tgross35 for after that is done |
|
Reminder, once the PR becomes ready for a review, use |
175584f to
82eb244
Compare
This comment has been minimized.
This comment has been minimized.
|
r=me once the ACP is approved. |
|
@bors delegate+ |
|
✌️ @jsimmons, you can now approve this pull request! If @joshtriplett told you to " |
|
ACP Accepted: rust-lang/libs-team#650 |
|
@bors r- |
82eb244 to
5400f9e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
library/std/src/thread/current.rs
Outdated
| /// }); | ||
| /// | ||
| /// let other_thread_id = other_thread.join().unwrap(); | ||
| /// assert!(thread::current_id() != other_thread_id); |
There was a problem hiding this comment.
| /// assert!(thread::current_id() != other_thread_id); | |
| /// assert_ne!(thread::current_id(), other_thread_id); |
5400f9e to
c081c87
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Accessing the thread id is often used in profiling and debugging, as well as some approaches for sound single-threaded access to data. Currently the only way to access the thread id is by first obtaining a handle to the current thread. While this is not exactly slow, it does require an atomic inc-ref and dec-ref operation, as well as the injection of `Thread`'s drop code into the caller. This publicly exposes the existing fast-path for accessing the current thread id.
c081c87 to
cbaec31
Compare
|
@bors r=joshtriplett,tgross35 |
Rollup of 6 pull requests Successful merges: - #143069 (Add fast-path for accessing the current thread id) - #146518 (Improve the documentation around `ZERO_AR_DATE`) - #146596 (Add a dummy codegen backend) - #146617 (Don’t suggest foreign `doc(hidden)` types in "the following other types implement trait" diagnostics) - #146635 (cg_llvm: Stop using `as_c_char_ptr` for coverage-related bindings) - #147184 (Fix the bevy implied bounds hack for the next solver) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 6 pull requests Successful merges: - #143069 (Add fast-path for accessing the current thread id) - #146518 (Improve the documentation around `ZERO_AR_DATE`) - #146596 (Add a dummy codegen backend) - #146617 (Don’t suggest foreign `doc(hidden)` types in "the following other types implement trait" diagnostics) - #146635 (cg_llvm: Stop using `as_c_char_ptr` for coverage-related bindings) - #147184 (Fix the bevy implied bounds hack for the next solver) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #143069 - jsimmons:current-thread-id-accessor, r=joshtriplett,tgross35 Add fast-path for accessing the current thread id Accessing the thread id is often used in profiling and debugging, as well as some approaches for sound single-threaded access to shared data. Currently the only way to access the thread id is by first obtaining a handle to the current thread. While this is not exactly slow, it does require an atomic inc-ref and dec-ref operation, as well as the injection of `Thread`'s drop code into the caller. This publicly exposes the existing fast-path for accessing the current thread id. edit: ACP: rust-lang/libs-team#650
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#143069 (Add fast-path for accessing the current thread id) - rust-lang#146518 (Improve the documentation around `ZERO_AR_DATE`) - rust-lang#146596 (Add a dummy codegen backend) - rust-lang#146617 (Don’t suggest foreign `doc(hidden)` types in "the following other types implement trait" diagnostics) - rust-lang#146635 (cg_llvm: Stop using `as_c_char_ptr` for coverage-related bindings) - rust-lang#147184 (Fix the bevy implied bounds hack for the next solver) r? `@ghost` `@rustbot` modify labels: rollup
Accessing the thread id is often used in profiling and debugging, as well as some approaches for sound single-threaded access to shared data.
Currently the only way to access the thread id is by first obtaining a handle to the current thread. While this is not exactly slow, it does require an atomic inc-ref and dec-ref operation, as well as the injection of
Thread's drop code into the caller.This publicly exposes the existing fast-path for accessing the current thread id.
edit: ACP: rust-lang/libs-team#650