]>
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 extern crate crossbeam_channel
;
5 extern crate crossbeam_utils
;
8 use std
::time
::Duration
;
10 use crossbeam_channel
::unbounded
;
11 use crossbeam_utils
::thread
::scope
;
13 fn ms(ms
: u64) -> Duration
{
14 Duration
::from_millis(ms
)
18 #[cfg_attr(target_os = "macos", ignore = "TLS is destroyed too early on macOS")]
19 fn use_while_exiting() {
24 // A blocking operation after the thread-locals have been dropped. This will attempt to
25 // use the thread-locals and must not panic.
26 let (_s
, r
) = unbounded
::<()>();
29 default(ms(100)) => {}
35 static FOO
: Foo
= Foo
;
38 let (s
, r
) = unbounded
::<()>();
42 // First initialize `FOO`, then the thread-locals related to crossbeam-channel.
45 // At thread exit, thread-locals related to crossbeam-channel get dropped first and
46 // `FOO` is dropped last.
50 thread
::sleep(ms(100));