diff options
| author | Eduardo Sánchez Muñoz <esm@eduardosm.net> | 2020-05-26 17:38:22 +0200 |
|---|---|---|
| committer | Eduardo Sánchez Muñoz <esm@eduardosm.net> | 2020-05-26 17:46:10 +0200 |
| commit | f03cf9916a1932f47b788a9de9256269cc172fe9 (patch) | |
| tree | 6ae5e84172fdf68053b59f8b8f1f641af50d3bf7 /src/libstd/rt.rs | |
| parent | cb272d5d21c94f9a460d68d76817227a5913fbf7 (diff) | |
Add a fast path for `std::thread::panicking`.
This is done by adding a global atomic variable (non-TLS) that counts how many threads are panicking. In order to check if the current thread is panicking, this variable is read and, if it is zero, no thread (including the one where `panicking` is being called) is panicking and `panicking` can return `false` immediately without needing to access TLS. If the global counter is not zero, the local counter is accessed from TLS to check if the current thread is panicking.
Diffstat (limited to 'src/libstd/rt.rs')
| -rw-r--r-- | src/libstd/rt.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstd/rt.rs b/src/libstd/rt.rs index 2426b2dead7..fb825ab16eb 100644 --- a/src/libstd/rt.rs +++ b/src/libstd/rt.rs @@ -15,7 +15,7 @@ #![doc(hidden)] // Re-export some of our utilities which are expected by other crates. -pub use crate::panicking::{begin_panic, begin_panic_fmt, update_panic_count}; +pub use crate::panicking::{begin_panic, begin_panic_fmt, panic_count}; // To reduce the generated code of the new `lang_start`, this function is doing // the real work. |
