]>
git.proxmox.com Git - rustc.git/blob - vendor/crossbeam-channel/tests/thread_locals.rs
1 //! Tests that make sure accessing thread-locals while exiting the thread doesn't cause panics.
4 use std
::time
::Duration
;
6 use crossbeam_channel
::{select, unbounded}
;
7 use crossbeam_utils
::thread
::scope
;
9 fn ms(ms
: u64) -> Duration
{
10 Duration
::from_millis(ms
)
14 #[cfg_attr(target_os = "macos", ignore = "TLS is destroyed too early on macOS")]
15 fn use_while_exiting() {
20 // A blocking operation after the thread-locals have been dropped. This will attempt to
21 // use the thread-locals and must not panic.
22 let (_s
, r
) = unbounded
::<()>();
25 default(ms(100)) => {}
31 static FOO
: Foo
= Foo
;
34 let (s
, r
) = unbounded
::<()>();
38 // First initialize `FOO`, then the thread-locals related to crossbeam-channel.
41 // At thread exit, thread-locals related to crossbeam-channel get dropped first and
42 // `FOO` is dropped last.
46 thread
::sleep(ms(100));