rayonパッケージ
Revisión | 9b92c7deb93aedda14ca4401c5fc40a7cff596b0 (tree) |
---|---|
Tiempo | 2019-12-20 04:52:51 |
Autor | Josh Stone <cuviper@gmai...> |
Commiter | Josh Stone |
cargo fmt
@@ -1,9 +1,9 @@ | ||
1 | -use crossbeam_queue::SegQueue; | |
2 | 1 | use crate::latch::Latch; |
2 | +use crate::unwind; | |
3 | +use crossbeam_queue::SegQueue; | |
3 | 4 | use std::any::Any; |
4 | 5 | use std::cell::UnsafeCell; |
5 | 6 | use std::mem; |
6 | -use crate::unwind; | |
7 | 7 | |
8 | 8 | pub(super) enum JobResult<T> { |
9 | 9 | None, |
@@ -2,8 +2,8 @@ use crate::job::StackJob; | ||
2 | 2 | use crate::latch::{LatchProbe, SpinLatch}; |
3 | 3 | use crate::log::Event::*; |
4 | 4 | use crate::registry::{self, WorkerThread}; |
5 | -use std::any::Any; | |
6 | 5 | use crate::unwind; |
6 | +use std::any::Any; | |
7 | 7 | |
8 | 8 | use crate::FnContext; |
9 | 9 |
@@ -1,11 +1,11 @@ | ||
1 | 1 | //! Tests for the join code. |
2 | 2 | |
3 | 3 | use crate::join::*; |
4 | +use crate::unwind; | |
5 | +use crate::ThreadPoolBuilder; | |
4 | 6 | use rand::distributions::Standard; |
5 | 7 | use rand::{Rng, SeedableRng}; |
6 | 8 | use rand_xorshift::XorShiftRng; |
7 | -use crate::unwind; | |
8 | -use crate::ThreadPoolBuilder; | |
9 | 9 | |
10 | 10 | fn quick_sort<T: PartialOrd + Send>(v: &mut [T]) { |
11 | 11 | if v.len() <= 1 { |
@@ -1,9 +1,14 @@ | ||
1 | -use crossbeam_deque::{Steal, Stealer, Worker}; | |
2 | -use crossbeam_queue::SegQueue; | |
3 | 1 | use crate::job::{JobFifo, JobRef, StackJob}; |
4 | 2 | use crate::latch::{CountLatch, Latch, LatchProbe, LockLatch, SpinLatch, TickleLatch}; |
5 | 3 | use crate::log::Event::*; |
6 | 4 | use crate::sleep::Sleep; |
5 | +use crate::unwind; | |
6 | +use crate::util::leak; | |
7 | +use crate::{ | |
8 | + ErrorKind, ExitHandler, PanicHandler, StartHandler, ThreadPoolBuildError, ThreadPoolBuilder, | |
9 | +}; | |
10 | +use crossbeam_deque::{Steal, Stealer, Worker}; | |
11 | +use crossbeam_queue::SegQueue; | |
7 | 12 | use std::any::Any; |
8 | 13 | use std::cell::Cell; |
9 | 14 | use std::collections::hash_map::DefaultHasher; |
@@ -18,9 +23,6 @@ use std::sync::atomic::{AtomicUsize, Ordering}; | ||
18 | 23 | use std::sync::{Arc, Once}; |
19 | 24 | use std::thread; |
20 | 25 | use std::usize; |
21 | -use crate::unwind; | |
22 | -use crate::util::leak; | |
23 | -use crate::{ErrorKind, ExitHandler, PanicHandler, StartHandler, ThreadPoolBuildError, ThreadPoolBuilder}; | |
24 | 26 | |
25 | 27 | /// Thread builder used for customization via |
26 | 28 | /// [`ThreadPoolBuilder::spawn_handler`](struct.ThreadPoolBuilder.html#method.spawn_handler). |
@@ -8,6 +8,7 @@ use crate::job::{HeapJob, JobFifo}; | ||
8 | 8 | use crate::latch::{CountLatch, Latch}; |
9 | 9 | use crate::log::Event::*; |
10 | 10 | use crate::registry::{in_worker, Registry, WorkerThread}; |
11 | +use crate::unwind; | |
11 | 12 | use std::any::Any; |
12 | 13 | use std::fmt; |
13 | 14 | use std::marker::PhantomData; |
@@ -15,7 +16,6 @@ use std::mem; | ||
15 | 16 | use std::ptr; |
16 | 17 | use std::sync::atomic::{AtomicPtr, Ordering}; |
17 | 18 | use std::sync::Arc; |
18 | -use crate::unwind; | |
19 | 19 | |
20 | 20 | #[cfg(test)] |
21 | 21 | mod test; |
@@ -1,3 +1,6 @@ | ||
1 | +use crate::unwind; | |
2 | +use crate::ThreadPoolBuilder; | |
3 | +use crate::{scope, scope_fifo, Scope}; | |
1 | 4 | use rand::{Rng, SeedableRng}; |
2 | 5 | use rand_xorshift::XorShiftRng; |
3 | 6 | use std::cmp; |
@@ -5,9 +8,6 @@ use std::iter::once; | ||
5 | 8 | use std::sync::atomic::{AtomicUsize, Ordering}; |
6 | 9 | use std::sync::Mutex; |
7 | 10 | use std::vec; |
8 | -use crate::unwind; | |
9 | -use crate::ThreadPoolBuilder; | |
10 | -use crate::{scope, scope_fifo, Scope}; | |
11 | 11 | |
12 | 12 | #[test] |
13 | 13 | fn scope_empty() { |
@@ -1,8 +1,8 @@ | ||
1 | 1 | use crate::job::*; |
2 | 2 | use crate::registry::Registry; |
3 | +use crate::unwind; | |
3 | 4 | use std::mem; |
4 | 5 | use std::sync::Arc; |
5 | -use crate::unwind; | |
6 | 6 | |
7 | 7 | /// Fires off a task into the Rayon threadpool in the "static" or |
8 | 8 | /// "global" scope. Just like a standard thread, this task is not |
@@ -1,10 +1,10 @@ | ||
1 | 1 | #![cfg(test)] |
2 | 2 | |
3 | -use std::sync::atomic::{AtomicUsize, Ordering}; | |
4 | -use std::sync::{Arc, Barrier}; | |
5 | 3 | #[allow(deprecated)] |
6 | 4 | use crate::Configuration; |
7 | 5 | use crate::{ThreadPoolBuildError, ThreadPoolBuilder}; |
6 | +use std::sync::atomic::{AtomicUsize, Ordering}; | |
7 | +use std::sync::{Arc, Barrier}; | |
8 | 8 | |
9 | 9 | #[test] |
10 | 10 | fn worker_thread_index() { |
@@ -6,14 +6,14 @@ | ||
6 | 6 | use crate::join; |
7 | 7 | use crate::registry::{Registry, ThreadSpawn, WorkerThread}; |
8 | 8 | use crate::spawn; |
9 | -use std::error::Error; | |
10 | -use std::fmt; | |
11 | -use std::sync::Arc; | |
12 | 9 | #[allow(deprecated)] |
13 | 10 | use crate::Configuration; |
14 | 11 | use crate::{scope, Scope}; |
15 | 12 | use crate::{scope_fifo, ScopeFifo}; |
16 | 13 | use crate::{ThreadPoolBuildError, ThreadPoolBuilder}; |
14 | +use std::error::Error; | |
15 | +use std::fmt; | |
16 | +use std::sync::Arc; | |
17 | 17 | |
18 | 18 | mod test; |
19 | 19 |
@@ -42,10 +42,10 @@ extern crate serde_derive; // all | ||
42 | 42 | extern crate glium; // nbody |
43 | 43 | #[macro_use] |
44 | 44 | extern crate lazy_static; // find |
45 | -#[cfg(windows)] | |
46 | -extern crate winapi; // life | |
47 | 45 | #[cfg(test)] |
48 | 46 | extern crate test; |
47 | +#[cfg(windows)] | |
48 | +extern crate winapi; // life | |
49 | 49 | |
50 | 50 | const USAGE: &str = " |
51 | 51 | Usage: rayon-demo bench |
@@ -285,12 +285,7 @@ impl<'a> ParallelExtend<&'a char> for String { | ||
285 | 285 | } |
286 | 286 | |
287 | 287 | fn string_reserve<T: AsRef<str>>(string: &mut String, list: &LinkedList<Vec<T>>) { |
288 | - let len = list | |
289 | - .iter() | |
290 | - .flatten() | |
291 | - .map(T::as_ref) | |
292 | - .map(str::len) | |
293 | - .sum(); | |
288 | + let len = list.iter().flatten().map(T::as_ref).map(str::len).sum(); | |
294 | 289 | string.reserve(len); |
295 | 290 | } |
296 | 291 |
@@ -286,8 +286,8 @@ fn test_u128_opt_len() { | ||
286 | 286 | #[test] |
287 | 287 | #[cfg(target_pointer_width = "64")] |
288 | 288 | fn test_usize_i64_overflow() { |
289 | - use std::i64; | |
290 | 289 | use crate::ThreadPoolBuilder; |
290 | + use std::i64; | |
291 | 291 | |
292 | 292 | let iter = (-2..i64::MAX).into_par_iter(); |
293 | 293 | assert_eq!(iter.opt_len(), Some(i64::MAX as usize + 2)); |
@@ -191,8 +191,8 @@ fn test_u128_opt_len() { | ||
191 | 191 | #[test] |
192 | 192 | #[cfg(target_pointer_width = "64")] |
193 | 193 | fn test_usize_i64_overflow() { |
194 | - use std::i64; | |
195 | 194 | use crate::ThreadPoolBuilder; |
195 | + use std::i64; | |
196 | 196 | |
197 | 197 | let iter = (-2..=i64::MAX).into_par_iter(); |
198 | 198 | assert_eq!(iter.opt_len(), Some(i64::MAX as usize + 3)); |