|
|
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Used to create a new `ThreadPool` or to configure the global rayon thread pool."><title>ThreadPoolBuilder in rayon_core - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-ac92e1bbe349e143.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="rayon_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0 (07dca489a 2024-02-04)" data-channel="1.76.0" data-search-js="search-2b6ce74ff89ae146.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-f2adc0d6ca4d09fb.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-305769736d49e732.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-feafe1bb7466e4bd.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../rayon_core/index.html">rayon_core</a><span class="version">1.12.1</span></h2></div><h2 class="location"><a href="#">ThreadPoolBuilder</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.breadth_first">breadth_first</a></li><li><a href="#method.build">build</a></li><li><a href="#method.build_global">build_global</a></li><li><a href="#method.build_scoped">build_scoped</a></li><li><a href="#method.exit_handler">exit_handler</a></li><li><a href="#method.new">new</a></li><li><a href="#method.num_threads">num_threads</a></li><li><a href="#method.panic_handler">panic_handler</a></li><li><a href="#method.spawn_handler">spawn_handler</a></li><li><a href="#method.stack_size">stack_size</a></li><li><a href="#method.start_handler">start_handler</a></li><li><a href="#method.thread_name">thread_name</a></li><li><a href="#method.use_current_thread">use_current_thread</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Debug-for-ThreadPoolBuilder%3CS%3E">Debug</a></li><li><a href="#impl-Default-for-ThreadPoolBuilder">Default</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-RefUnwindSafe-for-ThreadPoolBuilder%3CS%3E">!RefUnwindSafe</a></li><li><a href="#impl-Send-for-ThreadPoolBuilder%3CS%3E">!Send</a></li><li><a href="#impl-Sync-for-ThreadPoolBuilder%3CS%3E">!Sync</a></li><li><a href="#impl-UnwindSafe-for-ThreadPoolBuilder%3CS%3E">!UnwindSafe</a></li><li><a href="#impl-Unpin-for-ThreadPoolBuilder%3CS%3E">Unpin</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T">Into<U></a></li><li><a href="#impl-Pointable-for-T">Pointable</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T">TryInto<U></a></li></ul></section><h2><a href="index.html">In crate rayon_core</a></h2></div></nav><div class="sidebar-resizer"></div>
|
|
|
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../rayon_core/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Struct <a href="index.html">rayon_core</a>::<wbr><a class="struct" href="#">ThreadPoolBuilder</a><button id="copy-path" title="Copy item path to clipboard"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../src/rayon_core/lib.rs.html#178-210">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><pre class="rust item-decl"><code>pub struct ThreadPoolBuilder<S = DefaultSpawn> { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Used to create a new <a href="struct.ThreadPool.html"><code>ThreadPool</code></a> or to configure the global rayon thread pool.</p>
|
|
|
<h3 id="creating-a-threadpool"><a href="#creating-a-threadpool">Creating a ThreadPool</a></h3>
|
|
|
<p>The following creates a thread pool with 22 threads.</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>pool = rayon::ThreadPoolBuilder::new().num_threads(<span class="number">22</span>).build().unwrap();</code></pre></div>
|
|
|
<p>To instead configure the global thread pool, use <a href="struct.ThreadPoolBuilder.html#method.build_global"><code>build_global()</code></a>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>rayon::ThreadPoolBuilder::new().num_threads(<span class="number">22</span>).build_global().unwrap();</code></pre></div>
|
|
|
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-ThreadPoolBuilder" class="impl"><a class="src rightside" href="../src/rayon_core/lib.rs.html#252-257">source</a><a href="#impl-ThreadPoolBuilder" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.ThreadPoolBuilder.html" title="struct rayon_core::ThreadPoolBuilder">ThreadPoolBuilder</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#254-256">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>() -> Self</h4></section></summary><div class="docblock"><p>Creates and returns a valid rayon thread pool builder, but does not initialize it.</p>
|
|
|
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-ThreadPoolBuilder%3CS%3E" class="impl"><a class="src rightside" href="../src/rayon_core/lib.rs.html#261-292">source</a><a href="#impl-ThreadPoolBuilder%3CS%3E" class="anchor">§</a><h3 class="code-header">impl<S> <a class="struct" href="struct.ThreadPoolBuilder.html" title="struct rayon_core::ThreadPoolBuilder">ThreadPoolBuilder</a><S><div class="where">where
|
|
|
S: ThreadSpawn,</div></h3></section></summary><div class="docblock"><p>Note: the <code>S: ThreadSpawn</code> constraint is an internal implementation detail for the
|
|
|
default spawn and those set by <a href="#method.spawn_handler"><code>spawn_handler</code></a>.</p>
|
|
|
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.build" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#266-268">source</a><h4 class="code-header">pub fn <a href="#method.build" class="fn">build</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.ThreadPool.html" title="struct rayon_core::ThreadPool">ThreadPool</a>, <a class="struct" href="struct.ThreadPoolBuildError.html" title="struct rayon_core::ThreadPoolBuildError">ThreadPoolBuildError</a>></h4></section></summary><div class="docblock"><p>Creates a new <code>ThreadPool</code> initialized using this configuration.</p>
|
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.build_global" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#287-291">source</a><h4 class="code-header">pub fn <a href="#method.build_global" class="fn">build_global</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="struct.ThreadPoolBuildError.html" title="struct rayon_core::ThreadPoolBuildError">ThreadPoolBuildError</a>></h4></section></summary><div class="docblock"><p>Initializes the global thread pool. This initialization is
|
|
|
<strong>optional</strong>. If you do not call this function, the thread pool
|
|
|
will be automatically initialized with the default
|
|
|
configuration. Calling <code>build_global</code> is not recommended, except
|
|
|
in two scenarios:</p>
|
|
|
<ul>
|
|
|
<li>You wish to change the default configuration.</li>
|
|
|
<li>You are running a benchmark, in which case initializing may
|
|
|
yield slightly more consistent results, since the worker threads
|
|
|
will already be ready to go even in the first iteration. But
|
|
|
this cost is minimal.</li>
|
|
|
</ul>
|
|
|
<p>Initialization of the global thread pool happens exactly
|
|
|
once. Once started, the configuration cannot be
|
|
|
changed. Therefore, if you call <code>build_global</code> a second time, it
|
|
|
will return an error. An <code>Ok</code> result indicates that this
|
|
|
is the first initialization of the thread pool.</p>
|
|
|
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-ThreadPoolBuilder-1" class="impl"><a class="src rightside" href="../src/rayon_core/lib.rs.html#294-354">source</a><a href="#impl-ThreadPoolBuilder-1" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.ThreadPoolBuilder.html" title="struct rayon_core::ThreadPoolBuilder">ThreadPoolBuilder</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.build_scoped" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#332-353">source</a><h4 class="code-header">pub fn <a href="#method.build_scoped" class="fn">build_scoped</a><W, F, R>(
|
|
|
self,
|
|
|
wrapper: W,
|
|
|
with_pool: F
|
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><R, <a class="struct" href="struct.ThreadPoolBuildError.html" title="struct rayon_core::ThreadPoolBuildError">ThreadPoolBuildError</a>><div class="where">where
|
|
|
W: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(<a class="struct" href="struct.ThreadBuilder.html" title="struct rayon_core::ThreadBuilder">ThreadBuilder</a>) + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>,
|
|
|
F: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&<a class="struct" href="struct.ThreadPool.html" title="struct rayon_core::ThreadPool">ThreadPool</a>) -> R,</div></h4></section></summary><div class="docblock"><p>Creates a scoped <code>ThreadPool</code> initialized using this configuration.</p>
|
|
|
<p>This is a convenience function for building a pool using <a href="https://doc.rust-lang.org/std/thread/fn.scope.html"><code>std::thread::scope</code></a>
|
|
|
to spawn threads in a <a href="#method.spawn_handler"><code>spawn_handler</code></a>.
|
|
|
The threads in this pool will start by calling <code>wrapper</code>, which should
|
|
|
do initialization and continue by calling <code>ThreadBuilder::run()</code>.</p>
|
|
|
<h5 id="examples"><a href="#examples">Examples</a></h5>
|
|
|
<p>A scoped pool may be useful in combination with scoped thread-local variables.</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
|
|
|
<span class="macro">scoped_tls::scoped_thread_local!</span>(<span class="kw">static </span>POOL_DATA: Vec<i32>);
|
|
|
|
|
|
<span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), rayon::ThreadPoolBuildError> {
|
|
|
<span class="kw">let </span>pool_data = <span class="macro">vec!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
|
|
|
|
|
|
<span class="comment">// We haven't assigned any TLS data yet.
|
|
|
</span><span class="macro">assert!</span>(!POOL_DATA.is_set());
|
|
|
|
|
|
rayon::ThreadPoolBuilder::new()
|
|
|
.build_scoped(
|
|
|
<span class="comment">// Borrow `pool_data` in TLS for each thread.
|
|
|
</span>|thread| POOL_DATA.set(<span class="kw-2">&</span>pool_data, || thread.run()),
|
|
|
<span class="comment">// Do some work that needs the TLS data.
|
|
|
</span>|pool| pool.install(|| <span class="macro">assert!</span>(POOL_DATA.is_set())),
|
|
|
)<span class="question-mark">?</span>;
|
|
|
|
|
|
<span class="comment">// Once we've returned, `pool_data` is no longer borrowed.
|
|
|
</span>drop(pool_data);
|
|
|
<span class="prelude-val">Ok</span>(())
|
|
|
}</code></pre></div>
|
|
|
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-ThreadPoolBuilder%3CS%3E-1" class="impl"><a class="src rightside" href="../src/rayon_core/lib.rs.html#356-675">source</a><a href="#impl-ThreadPoolBuilder%3CS%3E-1" class="anchor">§</a><h3 class="code-header">impl<S> <a class="struct" href="struct.ThreadPoolBuilder.html" title="struct rayon_core::ThreadPoolBuilder">ThreadPoolBuilder</a><S></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.spawn_handler" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#443-459">source</a><h4 class="code-header">pub fn <a href="#method.spawn_handler" class="fn">spawn_handler</a><F>(self, spawn: F) -> <a class="struct" href="struct.ThreadPoolBuilder.html" title="struct rayon_core::ThreadPoolBuilder">ThreadPoolBuilder</a><CustomSpawn<F>><div class="where">where
|
|
|
F: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="struct" href="struct.ThreadBuilder.html" title="struct rayon_core::ThreadBuilder">ThreadBuilder</a>) -> <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>>,</div></h4></section></summary><div class="docblock"><p>Sets a custom function for spawning threads.</p>
|
|
|
<p>Note that the threads will not exit until after the pool is dropped. It
|
|
|
is up to the caller to wait for thread termination if that is important
|
|
|
for any invariants. For instance, threads created in <a href="https://doc.rust-lang.org/std/thread/fn.scope.html"><code>std::thread::scope</code></a>
|
|
|
will be joined before that scope returns, and this will block indefinitely
|
|
|
if the pool is leaked. Furthermore, the global thread pool doesn’t terminate
|
|
|
until the entire process exits!</p>
|
|
|
<h5 id="examples-1"><a href="#examples-1">Examples</a></h5>
|
|
|
<p>A minimal spawn handler just needs to call <code>run()</code> from an independent thread.</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), rayon::ThreadPoolBuildError> {
|
|
|
<span class="kw">let </span>pool = rayon::ThreadPoolBuilder::new()
|
|
|
.spawn_handler(|thread| {
|
|
|
std::thread::spawn(|| thread.run());
|
|
|
<span class="prelude-val">Ok</span>(())
|
|
|
})
|
|
|
.build()<span class="question-mark">?</span>;
|
|
|
|
|
|
pool.install(|| <span class="macro">println!</span>(<span class="string">"Hello from my custom thread!"</span>));
|
|
|
<span class="prelude-val">Ok</span>(())
|
|
|
}</code></pre></div>
|
|
|
<p>The default spawn handler sets the name and stack size if given, and propagates
|
|
|
any errors from the thread builder.</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), rayon::ThreadPoolBuildError> {
|
|
|
<span class="kw">let </span>pool = rayon::ThreadPoolBuilder::new()
|
|
|
.spawn_handler(|thread| {
|
|
|
<span class="kw">let </span><span class="kw-2">mut </span>b = std::thread::Builder::new();
|
|
|
<span class="kw">if let </span><span class="prelude-val">Some</span>(name) = thread.name() {
|
|
|
b = b.name(name.to_owned());
|
|
|
}
|
|
|
<span class="kw">if let </span><span class="prelude-val">Some</span>(stack_size) = thread.stack_size() {
|
|
|
b = b.stack_size(stack_size);
|
|
|
}
|
|
|
b.spawn(|| thread.run())<span class="question-mark">?</span>;
|
|
|
<span class="prelude-val">Ok</span>(())
|
|
|
})
|
|
|
.build()<span class="question-mark">?</span>;
|
|
|
|
|
|
pool.install(|| <span class="macro">println!</span>(<span class="string">"Hello from my fully custom thread!"</span>));
|
|
|
<span class="prelude-val">Ok</span>(())
|
|
|
}</code></pre></div>
|
|
|
<p>This can also be used for a pool of scoped threads like <a href="https://docs.rs/crossbeam/0.8/crossbeam/fn.scope.html"><code>crossbeam::scope</code></a>,
|
|
|
or <a href="https://doc.rust-lang.org/std/thread/fn.scope.html"><code>std::thread::scope</code></a> introduced in Rust 1.63, which is encapsulated in
|
|
|
<a href="#method.build_scoped"><code>build_scoped</code></a>.</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), rayon::ThreadPoolBuildError> {
|
|
|
std::thread::scope(|scope| {
|
|
|
<span class="kw">let </span>pool = rayon::ThreadPoolBuilder::new()
|
|
|
.spawn_handler(|thread| {
|
|
|
<span class="kw">let </span><span class="kw-2">mut </span>builder = std::thread::Builder::new();
|
|
|
<span class="kw">if let </span><span class="prelude-val">Some</span>(name) = thread.name() {
|
|
|
builder = builder.name(name.to_string());
|
|
|
}
|
|
|
<span class="kw">if let </span><span class="prelude-val">Some</span>(size) = thread.stack_size() {
|
|
|
builder = builder.stack_size(size);
|
|
|
}
|
|
|
builder.spawn_scoped(scope, || {
|
|
|
<span class="comment">// Add any scoped initialization here, then run!
|
|
|
</span>thread.run()
|
|
|
})<span class="question-mark">?</span>;
|
|
|
<span class="prelude-val">Ok</span>(())
|
|
|
})
|
|
|
.build()<span class="question-mark">?</span>;
|
|
|
|
|
|
pool.install(|| <span class="macro">println!</span>(<span class="string">"Hello from my custom scoped thread!"</span>));
|
|
|
<span class="prelude-val">Ok</span>(())
|
|
|
})
|
|
|
}</code></pre></div>
|
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.thread_name" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#506-512">source</a><h4 class="code-header">pub fn <a href="#method.thread_name" class="fn">thread_name</a><F>(self, closure: F) -> Self<div class="where">where
|
|
|
F: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Sets a closure which takes a thread index and returns
|
|
|
the thread’s name.</p>
|
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.num_threads" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#539-542">source</a><h4 class="code-header">pub fn <a href="#method.num_threads" class="fn">num_threads</a>(self, num_threads: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>) -> Self</h4></section></summary><div class="docblock"><p>Sets the number of threads to be used in the rayon threadpool.</p>
|
|
|
<p>If you specify a non-zero number of threads using this
|
|
|
function, then the resulting thread-pools are guaranteed to
|
|
|
start at most this number of threads.</p>
|
|
|
<p>If <code>num_threads</code> is 0, or you do not call this function, then
|
|
|
the Rayon runtime will select the number of threads
|
|
|
automatically. At present, this is based on the
|
|
|
<code>RAYON_NUM_THREADS</code> environment variable (if set),
|
|
|
or the number of logical CPUs (otherwise).
|
|
|
In the future, however, the default behavior may
|
|
|
change to dynamically add or remove threads as needed.</p>
|
|
|
<p><strong>Future compatibility warning:</strong> Given the default behavior
|
|
|
may change in the future, if you wish to rely on a fixed
|
|
|
number of threads, you should use this function to specify
|
|
|
that number. To reproduce the current default behavior, you
|
|
|
may wish to use <a href="https://doc.rust-lang.org/1.76.0/std/thread/fn.available_parallelism.html" title="fn std::thread::available_parallelism"><code>std::thread::available_parallelism</code></a>
|
|
|
to query the number of CPUs dynamically.</p>
|
|
|
<p><strong>Old environment variable:</strong> <code>RAYON_NUM_THREADS</code> is a one-to-one
|
|
|
replacement of the now deprecated <code>RAYON_RS_NUM_CPUS</code> environment
|
|
|
variable. If both variables are specified, <code>RAYON_NUM_THREADS</code> will
|
|
|
be preferred.</p>
|
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.use_current_thread" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#557-560">source</a><h4 class="code-header">pub fn <a href="#method.use_current_thread" class="fn">use_current_thread</a>(self) -> Self</h4></section></summary><div class="docblock"><p>Use the current thread as one of the threads in the pool.</p>
|
|
|
<p>The current thread is guaranteed to be at index 0, and since the thread is not managed by
|
|
|
rayon, the spawn and exit handlers do not run for that thread.</p>
|
|
|
<p>Note that the current thread won’t run the main work-stealing loop, so jobs spawned into
|
|
|
the thread-pool will generally not be picked up automatically by this thread unless you
|
|
|
yield to rayon in some way, like via <a href="fn.yield_now.html" title="fn rayon_core::yield_now"><code>yield_now()</code></a>, <a href="fn.yield_local.html" title="fn rayon_core::yield_local"><code>yield_local()</code></a>, or <a href="fn.scope.html" title="fn rayon_core::scope"><code>scope()</code></a>.</p>
|
|
|
<h5 id="local-thread-pools"><a href="#local-thread-pools">Local thread-pools</a></h5>
|
|
|
<p>Using this in a local thread-pool means the registry will be leaked. In future versions
|
|
|
there might be a way of cleaning up the current-thread state.</p>
|
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.panic_handler" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#581-587">source</a><h4 class="code-header">pub fn <a href="#method.panic_handler" class="fn">panic_handler</a><H>(self, panic_handler: H) -> Self<div class="where">where
|
|
|
H: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(<a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><dyn <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>>) + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Normally, whenever Rayon catches a panic, it tries to
|
|
|
propagate it to someplace sensible, to try and reflect the
|
|
|
semantics of sequential execution. But in some cases,
|
|
|
particularly with the <code>spawn()</code> APIs, there is no
|
|
|
obvious place where we should propagate the panic to.
|
|
|
In that case, this panic handler is invoked.</p>
|
|
|
<p>If no panic handler is set, the default is to abort the
|
|
|
process, under the principle that panics should not go
|
|
|
unobserved.</p>
|
|
|
<p>If the panic handler itself panics, this will abort the
|
|
|
process. To prevent this, wrap the body of your panic handler
|
|
|
in a call to <code>std::panic::catch_unwind()</code>.</p>
|
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.stack_size" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#595-598">source</a><h4 class="code-header">pub fn <a href="#method.stack_size" class="fn">stack_size</a>(self, stack_size: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>) -> Self</h4></section></summary><div class="docblock"><p>Sets the stack size of the worker threads</p>
|
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.breadth_first" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#629-632">source</a><h4 class="code-header">pub fn <a href="#method.breadth_first" class="fn">breadth_first</a>(self) -> Self</h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated: use <code>scope_fifo</code> and <code>spawn_fifo</code> for similar effect</span></div></span></summary><div class="docblock"><p><strong>(DEPRECATED)</strong> Suggest to worker threads that they execute
|
|
|
spawned jobs in a “breadth-first” fashion.</p>
|
|
|
<p>Typically, when a worker thread is idle or blocked, it will
|
|
|
attempt to execute the job from the <em>top</em> of its local deque of
|
|
|
work (i.e., the job most recently spawned). If this flag is set
|
|
|
to true, however, workers will prefer to execute in a
|
|
|
<em>breadth-first</em> fashion – that is, they will search for jobs at
|
|
|
the <em>bottom</em> of their local deque. (At present, workers <em>always</em>
|
|
|
steal from the bottom of other workers’ deques, regardless of
|
|
|
the setting of this flag.)</p>
|
|
|
<p>If you think of the tasks as a tree, where a parent task
|
|
|
spawns its children in the tree, then this flag loosely
|
|
|
corresponds to doing a breadth-first traversal of the tree,
|
|
|
whereas the default would be to do a depth-first traversal.</p>
|
|
|
<p><strong>Note that this is an “execution hint”.</strong> Rayon’s task
|
|
|
execution is highly dynamic and the precise order in which
|
|
|
independent tasks are executed is not intended to be
|
|
|
guaranteed.</p>
|
|
|
<p>This <code>breadth_first()</code> method is now deprecated per <a href="https://github.com/rayon-rs/rfcs/blob/master/accepted/rfc0001-scope-scheduling.md">RFC #1</a>,
|
|
|
and in the future its effect may be removed. Consider using
|
|
|
<a href="fn.scope_fifo.html"><code>scope_fifo()</code></a> for a similar effect.</p>
|
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.start_handler" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#649-655">source</a><h4 class="code-header">pub fn <a href="#method.start_handler" class="fn">start_handler</a><H>(self, start_handler: H) -> Self<div class="where">where
|
|
|
H: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>) + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Sets a callback to be invoked on thread start.</p>
|
|
|
<p>The closure is passed the index of the thread on which it is invoked.
|
|
|
Note that this same closure may be invoked multiple times in parallel.
|
|
|
If this closure panics, the panic will be passed to the panic handler.
|
|
|
If that handler returns, then startup will continue normally.</p>
|
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.exit_handler" class="method"><a class="src rightside" href="../src/rayon_core/lib.rs.html#668-674">source</a><h4 class="code-header">pub fn <a href="#method.exit_handler" class="fn">exit_handler</a><H>(self, exit_handler: H) -> Self<div class="where">where
|
|
|
H: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>) + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Sets a callback to be invoked on thread exit.</p>
|
|
|
<p>The closure is passed the index of the thread on which it is invoked.
|
|
|
Note that this same closure may be invoked multiple times in parallel.
|
|
|
If this closure panics, the panic will be passed to the panic handler.
|
|
|
If that handler returns, then the thread will exit normally.</p>
|
|
|
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-ThreadPoolBuilder%3CS%3E" class="impl"><a class="src rightside" href="../src/rayon_core/lib.rs.html#802-840">source</a><a href="#impl-Debug-for-ThreadPoolBuilder%3CS%3E" class="anchor">§</a><h3 class="code-header">impl<S> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.ThreadPoolBuilder.html" title="struct rayon_core::ThreadPoolBuilder">ThreadPoolBuilder</a><S></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../src/rayon_core/lib.rs.html#803-839">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.76.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Default-for-ThreadPoolBuilder" class="impl"><a class="src rightside" href="../src/rayon_core/lib.rs.html#236-250">source</a><a href="#impl-Default-for-ThreadPoolBuilder" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="struct.ThreadPoolBuilder.html" title="struct rayon_core::ThreadPoolBuilder">ThreadPoolBuilder</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.default" class="method trait-impl"><a class="src rightside" href="../src/rayon_core/lib.rs.html#237-249">source</a><a href="#method.default" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/default/trait.Default.html#tymethod.default" class="fn">default</a>() -> Self</h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a href="https://doc.rust-lang.org/1.76.0/core/default/trait.Default.html#tymethod.default">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-ThreadPoolBuilder%3CS%3E" class="impl"><a href="#impl-RefUnwindSafe-for-ThreadPoolBuilder%3CS%3E" class="anchor">§</a><h3 class="code-header">impl<S = DefaultSpawn> !<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.ThreadPoolBuilder.html" title="struct rayon_core::ThreadPoolBuilder">ThreadPoolBuilder</a><S></h3></section><section id="impl-Send-for-ThreadPoolBuilder%3CS%3E" class="impl"><a href="#impl-Send-for-ThreadPoolBuilder%3CS%3E" class="anchor">§</a><h3 class="code-header">impl<S = DefaultSpawn> !<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.ThreadPoolBuilder.html" title="struct rayon_core::ThreadPoolBuilder">ThreadPoolBuilder</a><S></h3></section><section id="impl-Sync-for-ThreadPoolBuilder%3CS%3E" class="impl"><a href="#impl-Sync-for-ThreadPoolBuilder%3CS%3E" class="anchor">§</a><h3 class="code-header">impl<S = DefaultSpawn> !<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.ThreadPoolBuilder.html" title="struct rayon_core::ThreadPoolBuilder">ThreadPoolBuilder</a><S></h3></section><section id="impl-Unpin-for-ThreadPoolBuilder%3CS%3E" class="impl"><a href="#impl-Unpin-for-ThreadPoolBuilder%3CS%3E" class="anchor">§</a><h3 class="code-header">impl<S> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.ThreadPoolBuilder.html" title="struct rayon_core::ThreadPoolBuilder">ThreadPoolBuilder</a><S><div class="where">where
|
|
|
S: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h3></section><section id="impl-UnwindSafe-for-ThreadPoolBuilder%3CS%3E" class="impl"><a href="#impl-UnwindSafe-for-ThreadPoolBuilder%3CS%3E" class="anchor">§</a><h3 class="code-header">impl<S = DefaultSpawn> !<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.ThreadPoolBuilder.html" title="struct rayon_core::ThreadPoolBuilder">ThreadPoolBuilder</a><S></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/any.rs.html#140">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
|
|
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
|
|
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
|
|
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#763">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#766">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
|
|
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#747-749">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
|
|
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#756">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
|
|
<p>That is, this conversion is whatever the implementation of
|
|
|
<code><a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
|
|
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Pointable-for-T" class="impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#194">source</a><a href="#impl-Pointable-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="../crossbeam_epoch/atomic/trait.Pointable.html" title="trait crossbeam_epoch::atomic::Pointable">Pointable</a> for T</h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedconstant.ALIGN" class="associatedconstant trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#195">source</a><a href="#associatedconstant.ALIGN" class="anchor">§</a><h4 class="code-header">const <a href="../crossbeam_epoch/atomic/trait.Pointable.html#associatedconstant.ALIGN" class="constant">ALIGN</a>: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a> = _</h4></section></summary><div class='docblock'>The alignment of pointer.</div></details><details class="toggle" open><summary><section id="associatedtype.Init" class="associatedtype trait-impl"><a href="#associatedtype.Init" class="anchor">§</a><h4 class="code-header">type <a href="../crossbeam_epoch/atomic/trait.Pointable.html#associatedtype.Init" class="associatedtype">Init</a> = T</h4></section></summary><div class='docblock'>The type for initializers.</div></details><details class="toggle method-toggle" open><summary><section id="method.init" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#199">source</a><a href="#method.init" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="../crossbeam_epoch/atomic/trait.Pointable.html#tymethod.init" class="fn">init</a>(init: <T as <a class="trait" href="../crossbeam_epoch/atomic/trait.Pointable.html" title="trait crossbeam_epoch::atomic::Pointable">Pointable</a>>::<a class="associatedtype" href="../crossbeam_epoch/atomic/trait.Pointable.html#associatedtype.Init" title="type crossbeam_epoch::atomic::Pointable::Init">Init</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a></h4></section></summary><div class='docblock'>Initializes a with the given initializer. <a href="../crossbeam_epoch/atomic/trait.Pointable.html#tymethod.init">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.deref" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#203">source</a><a href="#method.deref" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="../crossbeam_epoch/atomic/trait.Pointable.html#tymethod.deref" class="fn">deref</a><'a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&'a T</a></h4></section></summary><div class='docblock'>Dereferences the given pointer. <a href="../crossbeam_epoch/atomic/trait.Pointable.html#tymethod.deref">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.deref_mut" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#207">source</a><a href="#method.deref_mut" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="../crossbeam_epoch/atomic/trait.Pointable.html#tymethod.deref_mut" class="fn">deref_mut</a><'a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&'a mut T</a></h4></section></summary><div class='docblock'>Mutably dereferences the given pointer. <a href="../crossbeam_epoch/atomic/trait.Pointable.html#tymethod.deref_mut">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.drop" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#211">source</a><a href="#method.drop" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="../crossbeam_epoch/atomic/trait.Pointable.html#tymethod.drop" class="fn">drop</a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>)</h4></section></summary><div class='docblock'>Drops the object pointed to by the given pointer. <a href="../crossbeam_epoch/atomic/trait.Pointable.html#tymethod.drop">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#803-805">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
|
|
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#810">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#788-790">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
|
|
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#795">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html> |