]> git.proxmox.com Git - rustc.git/blob - src/vendor/rustc-rayon/src/lib.rs
New upstream version 1.28.0~beta.14+dfsg1
[rustc.git] / 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))]
5 #![deny(missing_docs)]
6
7 //! Data-parallelism library that makes it easy to convert sequential
8 //! computations into parallel
9 //!
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.
13 //!
14 //! # How to use Rayon
15 //!
16 //! There are two ways to use Rayon:
17 //!
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
29 //! the global one.
30 //!
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
37 //!
38 //! # Basic usage and the Rayon prelude
39 //!
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`).
42 //!
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.
48 //!
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].
52 //!
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
59 //!
60 //! # Crate Layout
61 //!
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
70 //! explicitly.
71 //!
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/
75 //!
76 //! # Other questions?
77 //!
78 //! See [the Rayon FAQ][faq].
79 //!
80 //! [faq]: https://github.com/rayon-rs/rayon/blob/master/FAQ.md
81
82 extern crate rustc_rayon_core as rayon_core;
83 extern crate either;
84
85 #[cfg(test)]
86 extern crate rand;
87
88 #[macro_use]
89 mod delegate;
90
91 #[macro_use]
92 mod private;
93
94 mod split_producer;
95
96 pub mod collections;
97 pub mod iter;
98 pub mod option;
99 pub mod prelude;
100 pub mod range;
101 pub mod result;
102 pub mod slice;
103 pub mod str;
104 pub mod vec;
105
106 mod par_either;
107 mod math;
108 mod test;
109
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;