aboutsummaryrefslogtreecommitdiff
path: root/vendor/rayon-core/tests/scoped_threadpool.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/rayon-core/tests/scoped_threadpool.rs
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/rayon-core/tests/scoped_threadpool.rs')
-rw-r--r--vendor/rayon-core/tests/scoped_threadpool.rs99
1 files changed, 0 insertions, 99 deletions
diff --git a/vendor/rayon-core/tests/scoped_threadpool.rs b/vendor/rayon-core/tests/scoped_threadpool.rs
deleted file mode 100644
index 9321471..0000000
--- a/vendor/rayon-core/tests/scoped_threadpool.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-use crossbeam_utils::thread;
-use rayon_core::ThreadPoolBuilder;
-
-#[derive(PartialEq, Eq, Debug)]
-struct Local(i32);
-
-scoped_tls::scoped_thread_local!(static LOCAL: Local);
-
-#[test]
-#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
-fn missing_scoped_tls() {
- LOCAL.set(&Local(42), || {
- let pool = ThreadPoolBuilder::new()
- .build()
- .expect("thread pool created");
-
- // `LOCAL` is not set in the pool.
- pool.install(|| {
- assert!(!LOCAL.is_set());
- });
- });
-}
-
-#[test]
-#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
-fn spawn_scoped_tls_threadpool() {
- LOCAL.set(&Local(42), || {
- LOCAL.with(|x| {
- thread::scope(|scope| {
- let pool = ThreadPoolBuilder::new()
- .spawn_handler(move |thread| {
- scope
- .builder()
- .spawn(move |_| {
- // Borrow the same local value in the thread pool.
- LOCAL.set(x, || thread.run())
- })
- .map(|_| ())
- })
- .build()
- .expect("thread pool created");
-
- // The pool matches our local value.
- pool.install(|| {
- assert!(LOCAL.is_set());
- LOCAL.with(|y| {
- assert_eq!(x, y);
- });
- });
-
- // If we change our local value, the pool is not affected.
- LOCAL.set(&Local(-1), || {
- pool.install(|| {
- assert!(LOCAL.is_set());
- LOCAL.with(|y| {
- assert_eq!(x, y);
- });
- });
- });
- })
- .expect("scope threads ok");
- // `thread::scope` will wait for the threads to exit before returning.
- });
- });
-}
-
-#[test]
-#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
-fn build_scoped_tls_threadpool() {
- LOCAL.set(&Local(42), || {
- LOCAL.with(|x| {
- ThreadPoolBuilder::new()
- .build_scoped(
- move |thread| LOCAL.set(x, || thread.run()),
- |pool| {
- // The pool matches our local value.
- pool.install(|| {
- assert!(LOCAL.is_set());
- LOCAL.with(|y| {
- assert_eq!(x, y);
- });
- });
-
- // If we change our local value, the pool is not affected.
- LOCAL.set(&Local(-1), || {
- pool.install(|| {
- assert!(LOCAL.is_set());
- LOCAL.with(|y| {
- assert_eq!(x, y);
- });
- });
- });
- },
- )
- .expect("thread pool created");
- // Internally, `std::thread::scope` will wait for the threads to exit before returning.
- });
- });
-}