diff options
author | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
---|---|---|
committer | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
commit | 1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch) | |
tree | 7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/flume/tests/thread_locals.rs | |
parent | 5ecd8cf2cba827454317368b68571df0d13d7842 (diff) | |
download | fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip |
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/flume/tests/thread_locals.rs')
-rw-r--r-- | vendor/flume/tests/thread_locals.rs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/flume/tests/thread_locals.rs b/vendor/flume/tests/thread_locals.rs new file mode 100644 index 0000000..acde751 --- /dev/null +++ b/vendor/flume/tests/thread_locals.rs @@ -0,0 +1,53 @@ +// //! Tests that make sure accessing thread-locals while exiting the thread doesn't cause panics. + +// extern crate crossbeam_utils; + +// use std::thread; +// use std::time::Duration; + +// use flume::unbounded; +// use crossbeam_utils::thread::scope; + +// fn ms(ms: u64) -> Duration { +// Duration::from_millis(ms) +// } + +// #[test] +// #[cfg_attr(target_os = "macos", ignore = "TLS is destroyed too early on macOS")] +// fn use_while_exiting() { +// struct Foo; + +// impl Drop for Foo { +// fn drop(&mut self) { +// // A blocking operation after the thread-locals have been dropped. This will attempt to +// // use the thread-locals and must not panic. +// let (_s, r) = unbounded::<()>(); +// select! { +// recv(r) -> _ => {} +// default(ms(100)) => {} +// } +// } +// } + +// thread_local! { +// static FOO: Foo = Foo; +// } + +// let (s, r) = unbounded::<()>(); + +// scope(|scope| { +// scope.spawn(|_| { +// // First initialize `FOO`, then the thread-locals related to crossbeam-channel. +// FOO.with(|_| ()); +// r.recv().unwrap(); +// // At thread exit, thread-locals related to crossbeam-channel get dropped first and +// // `FOO` is dropped last. +// }); + +// scope.spawn(|_| { +// thread::sleep(ms(100)); +// s.send(()).unwrap(); +// }); +// }) +// .unwrap(); +// } |