]>
git.proxmox.com Git - rustc.git/blob - src/vendor/rustc-rayon/src/lib.rs
1 #![doc(html_root_url = "https://docs.rs/rayon/1.0")]
2 #![deny(missing_debug_implementations)]
3 #![cfg_attr(test, feature(conservative_impl_trait))]
4 #![cfg_attr(test, feature(i128_type))]
7 //! Data-parallelism library that makes it easy to convert sequential
8 //! computations into parallel
10 //! Rayon is lightweight and convenient for introducing parallelism into existing
11 //! code. It guarantees data-race free executions and takes advantage of
12 //! parallelism when sensible, based on work-load at runtime.
14 //! # How to use Rayon
16 //! There are two ways to use Rayon:
18 //! - **High-level parallel constructs** are the simplest way to use Rayon and also
19 //! typically the most efficient.
20 //! - [Parallel iterators][iter module] make it easy to convert a sequential iterator to
21 //! execute in parallel.
22 //! - The [`par_sort`] method sorts `&mut [T]` slices (or vectors) in parallel.
23 //! - [`par_extend`] can be used to efficiently grow collections with items produced
24 //! by a parallel iterator.
25 //! - **Custom tasks** let you divide your work into parallel tasks yourself.
26 //! - [`join`] is used to subdivide a task into two pieces.
27 //! - [`scope`] creates a scope within which you can create any number of parallel tasks.
28 //! - [`ThreadPoolBuilder`] can be used to create your own thread pools or customize
31 //! [iter module]: iter/index.html
32 //! [`join`]: fn.join.html
33 //! [`scope`]: fn.scope.html
34 //! [`par_sort`]: slice/trait.ParallelSliceMut.html#method.par_sort
35 //! [`par_extend`]: iter/trait.ParallelExtend.html#tymethod.par_extend
36 //! [`ThreadPoolBuilder`]: struct.ThreadPoolBuilder.html
38 //! # Basic usage and the Rayon prelude
40 //! First, you will need to add `rayon` to your `Cargo.toml` and put
41 //! `extern crate rayon` in your main file (`lib.rs`, `main.rs`).
43 //! Next, to use parallel iterators or the other high-level methods,
44 //! you need to import several traits. Those traits are bundled into
45 //! the module [`rayon::prelude`]. It is recommended that you import
46 //! all of these traits at once by adding `use rayon::prelude::*` at
47 //! the top of each module that uses Rayon methods.
49 //! These traits give you access to the `par_iter` method which provides
50 //! parallel implementations of many iterative functions such as [`map`],
51 //! [`for_each`], [`filter`], [`fold`], and [more].
53 //! [`rayon::prelude::*`]: prelude/index.html
54 //! [`map`]: iter/trait.ParallelIterator.html#method.map
55 //! [`for_each`]: iter/trait.ParallelIterator.html#method.for_each
56 //! [`filter`]: iter/trait.ParallelIterator.html#method.filter
57 //! [`fold`]: iter/trait.ParallelIterator.html#method.fold
58 //! [more]: iter/trait.ParallelIterator.html#provided-methods
62 //! Rayon extends many of the types found in the standard library with
63 //! parallel iterator implementations. The modules in the `rayon`
64 //! crate mirror [`std`] itself: so, e.g., the `option` module in
65 //! Rayon contains parallel iterators for the `Option` type, which is
66 //! found in [the `option` module of `std`]. Similarly, the
67 //! `collections` module in Rayon offers parallel iterator types for
68 //! [the `collections` from `std`]. You will rarely need to access
69 //! these submodules unless you need to name iterator types
72 //! [the `option` module of `std`]: https://doc.rust-lang.org/std/option/index.html
73 //! [the `collections` from `std`]: https://doc.rust-lang.org/std/collections/index.html
74 //! [`std`]: https://doc.rust-lang.org/std/
76 //! # Other questions?
78 //! See [the Rayon FAQ][faq].
80 //! [faq]: https://github.com/rayon-rs/rayon/blob/master/FAQ.md
82 extern crate rustc_rayon_core
as rayon_core
;
110 pub use rayon_core
::current_num_threads
;
111 pub use rayon_core
::ThreadPool
;
112 pub use rayon_core
::ThreadPoolBuilder
;
113 pub use rayon_core
::ThreadPoolBuildError
;
114 pub use rayon_core
::{join, join_context}
;
115 pub use rayon_core
::FnContext
;
116 pub use rayon_core
::{scope, Scope}
;
117 pub use rayon_core
::spawn
;