Use rustc_thread_pool instead of rustc-rayon-core
This commit is contained in:
@@ -7,7 +7,7 @@ fn quick_sort<T:PartialOrd+Send>(v: &mut [T]) {
|
||||
|
||||
let mid = partition(v);
|
||||
let (lo, _hi) = v.split_at_mut(mid);
|
||||
rayon_core::join(|| quick_sort(lo), || quick_sort(lo)); //~ ERROR
|
||||
rustc_thred_pool::join(|| quick_sort(lo), || quick_sort(lo)); //~ ERROR
|
||||
}
|
||||
|
||||
fn partition<T:PartialOrd+Send>(v: &mut [T]) -> usize {
|
||||
|
||||
@@ -7,7 +7,7 @@ fn quick_sort<T:PartialOrd+Send>(v: &mut [T]) {
|
||||
|
||||
let mid = partition(v);
|
||||
let (lo, _hi) = v.split_at_mut(mid);
|
||||
rayon_core::join(|| quick_sort(lo), || quick_sort(v)); //~ ERROR
|
||||
rustc_thred_pool::join(|| quick_sort(lo), || quick_sort(v)); //~ ERROR
|
||||
}
|
||||
|
||||
fn partition<T:PartialOrd+Send>(v: &mut [T]) -> usize {
|
||||
|
||||
@@ -7,7 +7,7 @@ fn quick_sort<T:PartialOrd+Send>(v: &mut [T]) {
|
||||
|
||||
let mid = partition(v);
|
||||
let (_lo, hi) = v.split_at_mut(mid);
|
||||
rayon_core::join(|| quick_sort(hi), || quick_sort(hi)); //~ ERROR
|
||||
rustc_thred_pool::join(|| quick_sort(hi), || quick_sort(hi)); //~ ERROR
|
||||
}
|
||||
|
||||
fn partition<T:PartialOrd+Send>(v: &mut [T]) -> usize {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
rayon_core::join(|| Rc::new(22), || ()); //~ ERROR
|
||||
rustc_thred_pool::join(|| Rc::new(22), || ()); //~ ERROR
|
||||
|
||||
``` */
|
||||
mod left {}
|
||||
@@ -11,7 +11,7 @@ mod left {}
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
rayon_core::join(|| (), || Rc::new(23)); //~ ERROR
|
||||
rustc_thred_pool::join(|| (), || Rc::new(23)); //~ ERROR
|
||||
|
||||
``` */
|
||||
mod right {}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
let r = Rc::new(22);
|
||||
rayon_core::join(|| r.clone(), || r.clone());
|
||||
rustc_thred_pool::join(|| r.clone(), || r.clone());
|
||||
//~^ ERROR
|
||||
|
||||
``` */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
fn bad_scope<F>(f: F)
|
||||
where F: FnOnce(&i32) + Send,
|
||||
{
|
||||
rayon_core::scope(|s| {
|
||||
rustc_thred_pool::scope(|s| {
|
||||
let x = 22;
|
||||
s.spawn(|_| f(&x)); //~ ERROR `x` does not live long enough
|
||||
});
|
||||
@@ -13,7 +13,7 @@ fn good_scope<F>(f: F)
|
||||
where F: FnOnce(&i32) + Send,
|
||||
{
|
||||
let x = 22;
|
||||
rayon_core::scope(|s| {
|
||||
rustc_thred_pool::scope(|s| {
|
||||
s.spawn(|_| f(&x));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ mod test;
|
||||
/// [the `par_sort` method]: ../rayon/slice/trait.ParallelSliceMut.html#method.par_sort
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// let mut v = vec![5, 1, 8, 22, 0, 44];
|
||||
/// quick_sort(&mut v);
|
||||
/// assert_eq!(v, vec![0, 1, 5, 8, 22, 44]);
|
||||
|
||||
@@ -152,14 +152,14 @@ enum ErrorKind {
|
||||
/// The following creates a thread pool with 22 threads.
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// let pool = rayon::ThreadPoolBuilder::new().num_threads(22).build().unwrap();
|
||||
/// ```
|
||||
///
|
||||
/// To instead configure the global thread pool, use [`build_global()`]:
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// rayon::ThreadPoolBuilder::new().num_threads(22).build_global().unwrap();
|
||||
/// ```
|
||||
///
|
||||
@@ -315,7 +315,7 @@ impl ThreadPoolBuilder {
|
||||
/// A scoped pool may be useful in combination with scoped thread-local variables.
|
||||
///
|
||||
/// ```
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
///
|
||||
/// scoped_tls::scoped_thread_local!(static POOL_DATA: Vec<i32>);
|
||||
///
|
||||
@@ -382,7 +382,7 @@ impl<S> ThreadPoolBuilder<S> {
|
||||
/// A minimal spawn handler just needs to call `run()` from an independent thread.
|
||||
///
|
||||
/// ```
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// fn main() -> Result<(), rayon::ThreadPoolBuildError> {
|
||||
/// let pool = rayon::ThreadPoolBuilder::new()
|
||||
/// .spawn_handler(|thread| {
|
||||
@@ -400,7 +400,7 @@ impl<S> ThreadPoolBuilder<S> {
|
||||
/// any errors from the thread builder.
|
||||
///
|
||||
/// ```
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// fn main() -> Result<(), rayon::ThreadPoolBuildError> {
|
||||
/// let pool = rayon::ThreadPoolBuilder::new()
|
||||
/// .spawn_handler(|thread| {
|
||||
@@ -429,7 +429,7 @@ impl<S> ThreadPoolBuilder<S> {
|
||||
/// [`std::thread::scope`]: https://doc.rust-lang.org/std/thread/fn.scope.html
|
||||
///
|
||||
/// ```
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// fn main() -> Result<(), rayon::ThreadPoolBuildError> {
|
||||
/// std::thread::scope(|scope| {
|
||||
/// let pool = rayon::ThreadPoolBuilder::new()
|
||||
|
||||
@@ -84,7 +84,7 @@ struct ScopeBase<'scope> {
|
||||
/// it would be less efficient than the real implementation:
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// pub fn join<A,B,RA,RB>(oper_a: A, oper_b: B) -> (RA, RB)
|
||||
/// where A: FnOnce() -> RA + Send,
|
||||
/// B: FnOnce() -> RB + Send,
|
||||
@@ -125,7 +125,7 @@ struct ScopeBase<'scope> {
|
||||
/// To see how and when tasks are joined, consider this example:
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// // point start
|
||||
/// rayon::scope(|s| {
|
||||
/// s.spawn(|s| { // task s.1
|
||||
@@ -193,7 +193,7 @@ struct ScopeBase<'scope> {
|
||||
/// spawned task.
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// let ok: Vec<i32> = vec![1, 2, 3];
|
||||
/// rayon::scope(|s| {
|
||||
/// let bad: Vec<i32> = vec![4, 5, 6];
|
||||
@@ -217,7 +217,7 @@ struct ScopeBase<'scope> {
|
||||
/// in this case including both `ok` *and* `bad`:
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// let ok: Vec<i32> = vec![1, 2, 3];
|
||||
/// rayon::scope(|s| {
|
||||
/// let bad: Vec<i32> = vec![4, 5, 6];
|
||||
@@ -238,7 +238,7 @@ struct ScopeBase<'scope> {
|
||||
/// is a borrow of `ok` and capture *that*:
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// let ok: Vec<i32> = vec![1, 2, 3];
|
||||
/// rayon::scope(|s| {
|
||||
/// let bad: Vec<i32> = vec![4, 5, 6];
|
||||
@@ -260,7 +260,7 @@ struct ScopeBase<'scope> {
|
||||
/// of individual variables:
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// let ok: Vec<i32> = vec![1, 2, 3];
|
||||
/// rayon::scope(|s| {
|
||||
/// let bad: Vec<i32> = vec![4, 5, 6];
|
||||
@@ -312,7 +312,7 @@ where
|
||||
/// [`scope()`]: fn.scope.html
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// // point start
|
||||
/// rayon::scope_fifo(|s| {
|
||||
/// s.spawn_fifo(|s| { // task s.1
|
||||
@@ -487,7 +487,7 @@ impl<'scope> Scope<'scope> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// let mut value_a = None;
|
||||
/// let mut value_b = None;
|
||||
/// let mut value_c = None;
|
||||
|
||||
@@ -50,7 +50,7 @@ use crate::unwind;
|
||||
/// This code creates a Rayon task that increments a global counter.
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
|
||||
///
|
||||
/// static GLOBAL_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
|
||||
@@ -28,7 +28,7 @@ mod test;
|
||||
/// ## Creating a ThreadPool
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// let pool = rayon::ThreadPoolBuilder::new().num_threads(8).build().unwrap();
|
||||
/// ```
|
||||
///
|
||||
@@ -88,10 +88,10 @@ impl ThreadPool {
|
||||
/// meantime. For example
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// fn main() {
|
||||
/// rayon::ThreadPoolBuilder::new().num_threads(1).build_global().unwrap();
|
||||
/// let pool = rayon_core::ThreadPoolBuilder::default().build().unwrap();
|
||||
/// let pool = rustc_thred_pool::ThreadPoolBuilder::default().build().unwrap();
|
||||
/// let do_it = || {
|
||||
/// print!("one ");
|
||||
/// pool.install(||{});
|
||||
@@ -123,7 +123,7 @@ impl ThreadPool {
|
||||
/// ## Using `install()`
|
||||
///
|
||||
/// ```rust
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// fn main() {
|
||||
/// let pool = rayon::ThreadPoolBuilder::new().num_threads(8).build().unwrap();
|
||||
/// let n = pool.install(|| fib(20));
|
||||
@@ -172,7 +172,7 @@ impl ThreadPool {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use rayon_core as rayon;
|
||||
/// # use rustc_thred_pool as rayon;
|
||||
/// use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
///
|
||||
/// fn main() {
|
||||
|
||||
Reference in New Issue
Block a user