Adding large folders

This commit is contained in:
2026-02-26 12:00:21 -05:00
parent 5400d82acd
commit 49701c85ad
47332 changed files with 1942573 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/task/fn.block_in_place.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/task/fn.block_in_place.html">../../../tokio/task/fn.block_in_place.html</a>...</p>
<script>location.replace("../../../tokio/task/fn.block_in_place.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/task/fn.spawn_blocking.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/task/fn.spawn_blocking.html">../../../tokio/task/fn.spawn_blocking.html</a>...</p>
<script>location.replace("../../../tokio/task/fn.spawn_blocking.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../../tokio/task/coop/fn.consume_budget.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/task/coop/fn.consume_budget.html">../../../../tokio/task/coop/fn.consume_budget.html</a>...</p>
<script>location.replace("../../../../tokio/task/coop/fn.consume_budget.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,18 @@
<!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="Consumes a unit of budget and returns the execution back to the Tokio runtime if the tasks coop budget was exhausted."><title>consume_budget in tokio::task::coop - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">consume_budget</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">consume_<wbr>budget</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>task::<wbr>coop</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">task</a>::<wbr><a href="index.html">coop</a></div><h1>Function <span class="fn">consume_<wbr>budget</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/tokio/task/coop/consume_budget.rs.html#25-39">Source</a> </span></div><pre class="rust item-decl"><code>pub async fn consume_budget()</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Consumes a unit of budget and returns the execution back to the Tokio
runtime <em>if</em> the tasks coop budget was exhausted.</p>
<p>The task will only yield if its entire coop budget has been exhausted.
This function can be used in order to insert optional yield points into long
computations that do not use Tokio resources like sockets or semaphores,
without redundantly yielding to the runtime each time.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Make sure that a function which returns a sum of (potentially lots of)
iterated values is cooperative.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">async fn </span>sum_iterator(input: <span class="kw-2">&amp;mut </span><span class="kw">impl </span>std::iter::Iterator&lt;Item=i64&gt;) -&gt; i64 {
<span class="kw">let </span><span class="kw-2">mut </span>sum: i64 = <span class="number">0</span>;
<span class="kw">while let </span><span class="prelude-val">Some</span>(i) = input.next() {
sum += i;
tokio::task::consume_budget().<span class="kw">await
</span>}
sum
}</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,26 @@
<!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="Creates a wrapper future that makes the inner future cooperate with the Tokio scheduler."><title>cooperative in tokio::task::coop - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">cooperative</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">cooperative</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>task::<wbr>coop</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">task</a>::<wbr><a href="index.html">coop</a></div><h1>Function <span class="fn">cooperative</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/tokio/task/coop/mod.rs.html#490-492">Source</a> </span></div><pre class="rust item-decl"><code>pub fn cooperative&lt;F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;(fut: F) -&gt; <a class="struct" href="struct.Coop.html" title="struct tokio::task::coop::Coop">Coop</a>&lt;F&gt; <a href="#" class="tooltip" data-notable-ty="Coop&lt;F&gt;"></a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Creates a wrapper future that makes the inner future cooperate with the Tokio scheduler.</p>
<p>When polled, the wrapper will first call <a href="fn.poll_proceed.html" title="fn tokio::task::coop::poll_proceed"><code>poll_proceed</code></a> to consume task budget, and
immediately yield if the budget has been depleted. If budget was available, the inner future
is polled. The budget consumption will be made final using <a href="struct.RestoreOnPending.html#method.made_progress" title="method tokio::task::coop::RestoreOnPending::made_progress"><code>RestoreOnPending::made_progress</code></a>
if the inner future resolves to its final value.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>When you call <code>recv</code> on the <code>Receiver</code> of a <a href="../../sync/mpsc/index.html" title="mod tokio::sync::mpsc"><code>tokio::sync::mpsc</code></a>
channel, task budget will automatically be consumed when the next value is returned.
This makes tasks that use Tokio mpsc channels automatically cooperative.</p>
<p>If youre using <a href="https://docs.rs/futures/latest/futures/channel/mpsc/index.html"><code>futures::channel::mpsc</code></a>
instead, automatic task budget consumption will not happen. This example shows how can use
<code>cooperative</code> to make <code>futures::channel::mpsc</code> channels cooperate with the scheduler in the
same way Tokio channels do.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task::coop::cooperative;
<span class="kw">use </span>futures::channel::mpsc::Receiver;
<span class="kw">use </span>futures::stream::StreamExt;
<span class="kw">async fn </span>receive_next&lt;T&gt;(receiver: <span class="kw-2">&amp;mut </span>Receiver&lt;T&gt;) -&gt; <span class="prelude-ty">Option</span>&lt;T&gt; {
<span class="comment">// Use `StreamExt::next` to obtain a `Future` that resolves to the next value
</span><span class="kw">let </span>recv_future = receiver.next();
<span class="comment">// Wrap it a cooperative wrapper
</span><span class="kw">let </span>coop_future = cooperative(recv_future);
<span class="comment">// And await
</span>coop_future.<span class="kw">await
</span>}</code></pre></div></div></details><script type="text/json" id="notable-traits-data">{"Coop<F>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Coop.html\" title=\"struct tokio::task::coop::Coop\">Coop</a>&lt;F&gt;</code></h3><pre><code><div class=\"where\">impl&lt;F: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Coop.html\" title=\"struct tokio::task::coop::Coop\">Coop</a>&lt;F&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = F::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>;</div>"}</script></section></div></main></body></html>

View File

@@ -0,0 +1,41 @@
<!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="Returns `true` if there is still budget left on the task."><title>has_budget_remaining in tokio::task::coop - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">has_budget_remaining</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">has_<wbr>budget_<wbr>remaining</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>task::<wbr>coop</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">task</a>::<wbr><a href="index.html">coop</a></div><h1>Function <span class="fn">has_<wbr>budget_<wbr>remaining</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/tokio/task/coop/mod.rs.html#223-227">Source</a> </span></div><pre class="rust item-decl"><code>pub fn has_budget_remaining() -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returns <code>true</code> if there is still budget left on the task.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>This example defines a <code>Timeout</code> future that requires a given <code>future</code> to complete before the
specified duration elapses. If it does, its result is returned; otherwise, an error is returned
and the future is canceled.</p>
<p>Note that the future could exhaust the budget before we evaluate the timeout. Using <code>has_budget_remaining</code>,
we can detect this scenario and ensure the timeout is always checked.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">pub struct </span>Timeout&lt;T&gt; {
future: T,
delay: Pin&lt;Box&lt;Sleep&gt;&gt;,
}
<span class="kw">impl</span>&lt;T&gt; Future <span class="kw">for </span>Timeout&lt;T&gt;
<span class="kw">where
</span>T: Future + Unpin,
{
<span class="kw">type </span>Output = <span class="prelude-ty">Result</span>&lt;T::Output, ()&gt;;
<span class="kw">fn </span>poll(<span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;) -&gt; Poll&lt;<span class="self">Self</span>::Output&gt; {
<span class="kw">let </span>this = Pin::into_inner(<span class="self">self</span>);
<span class="kw">let </span>future = Pin::new(<span class="kw-2">&amp;mut </span>this.future);
<span class="kw">let </span>delay = Pin::new(<span class="kw-2">&amp;mut </span>this.delay);
<span class="comment">// check if the future is ready
</span><span class="kw">let </span>had_budget_before = coop::has_budget_remaining();
<span class="kw">if let </span>Poll::Ready(v) = future.poll(cx) {
<span class="kw">return </span>Poll::Ready(<span class="prelude-val">Ok</span>(v));
}
<span class="kw">let </span>has_budget_now = coop::has_budget_remaining();
<span class="comment">// evaluate the timeout
</span><span class="kw">if let </span>(<span class="bool-val">true</span>, <span class="bool-val">false</span>) = (had_budget_before, has_budget_now) {
<span class="comment">// it is the underlying future that exhausted the budget
</span><span class="macro">ready!</span>(<span class="macro">pin!</span>(coop::unconstrained(delay)).poll(cx));
} <span class="kw">else </span>{
<span class="macro">ready!</span>(delay.poll(cx));
}
<span class="kw">return </span>Poll::Ready(<span class="prelude-val">Err</span>(()));
}
}</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,45 @@
<!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="Decrements the task budget and returns `Poll::Pending` if the budget is depleted. This indicates that the task should yield to the scheduler. Otherwise, returns `RestoreOnPending` which can be used to commit the budget consumption."><title>poll_proceed in tokio::task::coop - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">poll_proceed</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">poll_<wbr>proceed</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>task::<wbr>coop</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">task</a>::<wbr><a href="index.html">coop</a></div><h1>Function <span class="fn">poll_<wbr>proceed</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/tokio/task/coop/mod.rs.html#343-364">Source</a> </span></div><pre class="rust item-decl"><code>pub fn poll_proceed(cx: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="struct" href="struct.RestoreOnPending.html" title="struct tokio::task::coop::RestoreOnPending">RestoreOnPending</a>&gt;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Decrements the task budget and returns <a href="https://doc.rust-lang.org/1.93.1/core/task/poll/enum.Poll.html#variant.Pending" title="variant core::task::poll::Poll::Pending"><code>Poll::Pending</code></a> if the budget is depleted.
This indicates that the task should yield to the scheduler. Otherwise, returns
<a href="struct.RestoreOnPending.html" title="struct tokio::task::coop::RestoreOnPending"><code>RestoreOnPending</code></a> which can be used to commit the budget consumption.</p>
<p>The returned <a href="struct.RestoreOnPending.html" title="struct tokio::task::coop::RestoreOnPending"><code>RestoreOnPending</code></a> will revert the budget to its former
value when dropped unless <a href="struct.RestoreOnPending.html#method.made_progress" title="method tokio::task::coop::RestoreOnPending::made_progress"><code>RestoreOnPending::made_progress</code></a>
is called. It is the callers responsibility to do so when it <em>was</em> able to
make progress after the call to <a href="fn.poll_proceed.html" title="fn tokio::task::coop::poll_proceed"><code>poll_proceed</code></a>.
Restoring the budget automatically ensures the task can try to make progress in some other
way.</p>
<p>Note that <a href="struct.RestoreOnPending.html" title="struct tokio::task::coop::RestoreOnPending"><code>RestoreOnPending</code></a> restores the budget <strong>as it was before <a href="fn.poll_proceed.html" title="fn tokio::task::coop::poll_proceed"><code>poll_proceed</code></a></strong>.
Therefore, if the budget is <em>further</em> adjusted between when <a href="fn.poll_proceed.html" title="fn tokio::task::coop::poll_proceed"><code>poll_proceed</code></a> returns and
<a href="struct.RestoreOnPending.html" title="struct tokio::task::coop::RestoreOnPending"><code>RestoreOnPending</code></a> is dropped, those adjustments are erased unless the caller indicates
that progress was made.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>This example wraps the <code>futures::channel::mpsc::UnboundedReceiver</code> to
cooperate with the Tokio scheduler. Each time a value is received, task budget
is consumed. If no budget is available, the task yields to the scheduler.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::pin::Pin;
<span class="kw">use </span>std::task::{ready, Context, Poll};
<span class="kw">use </span>tokio::task::coop;
<span class="kw">use </span>futures::stream::{Stream, StreamExt};
<span class="kw">use </span>futures::channel::mpsc::UnboundedReceiver;
<span class="kw">struct </span>CoopUnboundedReceiver&lt;T&gt; {
receiver: UnboundedReceiver&lt;T&gt;,
}
<span class="kw">impl</span>&lt;T&gt; Stream <span class="kw">for </span>CoopUnboundedReceiver&lt;T&gt; {
<span class="kw">type </span>Item = T;
<span class="kw">fn </span>poll_next(
<span class="kw-2">mut </span><span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;,
cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;
) -&gt; Poll&lt;<span class="prelude-ty">Option</span>&lt;T&gt;&gt; {
<span class="kw">let </span>coop = <span class="macro">ready!</span>(coop::poll_proceed(cx));
<span class="kw">match </span><span class="self">self</span>.receiver.poll_next_unpin(cx) {
Poll::Ready(v) =&gt; {
<span class="comment">// We received a value, so consume budget.
</span>coop.made_progress();
Poll::Ready(v)
}
Poll::Pending =&gt; Poll::Pending,
}
}
}</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,5 @@
<!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="Turn off cooperative scheduling for a future. The future will never be forced to yield by Tokio. Using this exposes your service to starvation if the unconstrained future never yields otherwise."><title>unconstrained in tokio::task::coop - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">unconstrained</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>task::<wbr>coop</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">task</a>::<wbr><a href="index.html">coop</a></div><h1>Function <span class="fn">unconstrained</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/tokio/task/coop/unconstrained.rs.html#43-45">Source</a> </span></div><pre class="rust item-decl"><code>pub fn unconstrained&lt;F&gt;(inner: F) -&gt; <a class="struct" href="struct.Unconstrained.html" title="struct tokio::task::coop::Unconstrained">Unconstrained</a>&lt;F&gt; <a href="#" class="tooltip" data-notable-ty="Unconstrained&lt;F&gt;"></a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Turn off cooperative scheduling for a future. The future will never be forced to yield by
Tokio. Using this exposes your service to starvation if the unconstrained future never yields
otherwise.</p>
<p>See also the usage example in the <a href="index.html#unconstrained">task module</a>.</p>
</div></details><script type="text/json" id="notable-traits-data">{"Unconstrained<F>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Unconstrained.html\" title=\"struct tokio::task::coop::Unconstrained\">Unconstrained</a>&lt;F&gt;</code></h3><pre><code><div class=\"where\">impl&lt;F&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Unconstrained.html\" title=\"struct tokio::task::coop::Unconstrained\">Unconstrained</a>&lt;F&gt;<div class=\"where\">where\n F: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>,</div></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = &lt;F as <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>&gt;::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>;</div>"}</script></section></div></main></body></html>

View File

@@ -0,0 +1,43 @@
<!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="Utilities for improved cooperative scheduling."><title>tokio::task::coop - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module coop</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module coop</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#cooperative-scheduling" title="Cooperative scheduling">Cooperative scheduling</a><ul><li><a href="#unconstrained" title="unconstrained">unconstrained</a></li></ul></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In tokio::<wbr>task</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">task</a></div><h1>Module <span>coop</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/tokio/task/coop/mod.rs.html#1-573">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Utilities for improved cooperative scheduling.</p>
<h4 id="cooperative-scheduling"><a class="doc-anchor" href="#cooperative-scheduling">§</a>Cooperative scheduling</h4>
<p>A single call to <a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#tymethod.poll" title="method core::future::future::Future::poll"><code>poll</code></a> on a top-level task may potentially do a lot of
work before it returns <code>Poll::Pending</code>. If a task runs for a long period of
time without yielding back to the executor, it can starve other tasks
waiting on that executor to execute them, or drive underlying resources.
Since Rust does not have a runtime, it is difficult to forcibly preempt a
long-running task. Instead, this module provides an opt-in mechanism for
futures to collaborate with the executor to avoid starvation.</p>
<p>Consider a future like this one:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">async fn </span>drop_all&lt;I: Stream + Unpin&gt;(<span class="kw-2">mut </span>input: I) {
<span class="kw">while let </span><span class="prelude-val">Some</span>(<span class="kw">_</span>) = input.next().<span class="kw">await </span>{}
}</code></pre></div>
<p>It may look harmless, but consider what happens under heavy load if the
input stream is <em>always</em> ready. If we spawn <code>drop_all</code>, the task will never
yield, and will starve other tasks and resources on the same executor.</p>
<p>To account for this, Tokio has explicit yield points in a number of library
functions, which force tasks to return to the executor periodically.</p>
<h5 id="unconstrained"><a class="doc-anchor" href="#unconstrained">§</a>unconstrained</h5>
<p>If necessary, <a href="fn.unconstrained.html" title="fn tokio::task::coop::unconstrained"><code>task::unconstrained</code></a> lets you opt a future out of Tokios cooperative
scheduling. When a future is wrapped with <code>unconstrained</code>, it will never be forced to yield to
Tokio. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::{task, sync::mpsc};
<span class="kw">let </span>fut = <span class="kw">async </span>{
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx) = mpsc::unbounded_channel();
<span class="kw">for </span>i <span class="kw">in </span><span class="number">0</span>..<span class="number">1000 </span>{
<span class="kw">let _ </span>= tx.send(());
<span class="comment">// This will always be ready. If coop was in effect, this code would be forced to yield
// periodically. However, if left unconstrained, then this code will never yield.
</span>rx.recv().<span class="kw">await</span>;
}
};
task::coop::unconstrained(fut).<span class="kw">await</span>;</code></pre></div></div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.Coop.html" title="struct tokio::task::coop::Coop">Coop</a></dt><dd>Future wrapper to ensure cooperative scheduling created by <a href="fn.cooperative.html" title="fn tokio::task::coop::cooperative"><code>cooperative</code></a>.</dd><dt><a class="struct" href="struct.RestoreOnPending.html" title="struct tokio::task::coop::RestoreOnPending">Restore<wbr>OnPending</a></dt><dd>Value returned by the <a href="fn.poll_proceed.html" title="fn tokio::task::coop::poll_proceed"><code>poll_proceed</code></a> method.</dd><dt><a class="struct" href="struct.Unconstrained.html" title="struct tokio::task::coop::Unconstrained">Unconstrained</a></dt><dd>Future for the <a href="fn.unconstrained.html" title="fn tokio::task::coop::unconstrained"><code>unconstrained</code></a> method.</dd></dl><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.consume_budget.html" title="fn tokio::task::coop::consume_budget">consume_<wbr>budget</a></dt><dd>Consumes a unit of budget and returns the execution back to the Tokio
runtime <em>if</em> the tasks coop budget was exhausted.</dd><dt><a class="fn" href="fn.cooperative.html" title="fn tokio::task::coop::cooperative">cooperative</a></dt><dd>Creates a wrapper future that makes the inner future cooperate with the Tokio scheduler.</dd><dt><a class="fn" href="fn.has_budget_remaining.html" title="fn tokio::task::coop::has_budget_remaining">has_<wbr>budget_<wbr>remaining</a></dt><dd>Returns <code>true</code> if there is still budget left on the task.</dd><dt><a class="fn" href="fn.poll_proceed.html" title="fn tokio::task::coop::poll_proceed">poll_<wbr>proceed</a></dt><dd>Decrements the task budget and returns <a href="https://doc.rust-lang.org/1.93.1/core/task/poll/enum.Poll.html#variant.Pending" title="variant core::task::poll::Poll::Pending"><code>Poll::Pending</code></a> if the budget is depleted.
This indicates that the task should yield to the scheduler. Otherwise, returns
<a href="struct.RestoreOnPending.html" title="struct tokio::task::coop::RestoreOnPending"><code>RestoreOnPending</code></a> which can be used to commit the budget consumption.</dd><dt><a class="fn" href="fn.unconstrained.html" title="fn tokio::task::coop::unconstrained">unconstrained</a></dt><dd>Turn off cooperative scheduling for a future. The future will never be forced to yield by
Tokio. Using this exposes your service to starvation if the unconstrained future never yields
otherwise.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"fn":["consume_budget","cooperative","has_budget_remaining","poll_proceed","unconstrained"],"struct":["Coop","RestoreOnPending","Unconstrained"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../../tokio/task/coop/fn.unconstrained.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/task/coop/fn.unconstrained.html">../../../../tokio/task/coop/fn.unconstrained.html</a>...</p>
<script>location.replace("../../../../tokio/task/coop/fn.unconstrained.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../../tokio/task/coop/struct.Unconstrained.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/task/coop/struct.Unconstrained.html">../../../../tokio/task/coop/struct.Unconstrained.html</a>...</p>
<script>location.replace("../../../../tokio/task/coop/struct.Unconstrained.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,45 @@
<!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="Runs the provided blocking function on the current thread without blocking the executor."><title>block_in_place in tokio::task - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">block_in_place</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">block_<wbr>in_<wbr>place</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#panics" title="Panics">Panics</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>task</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">task</a></div><h1>Function <span class="fn">block_<wbr>in_<wbr>place</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tokio/task/blocking.rs.html#74-79">Source</a> </span></div><pre class="rust item-decl"><code>pub fn block_in_place&lt;F, R&gt;(f: F) -&gt; R<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -&gt; R,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Runs the provided blocking function on the current thread without
blocking the executor.</p>
<p>In general, issuing a blocking call or performing a lot of compute in a
future without yielding is problematic, as it may prevent the executor
from driving other tasks forward. Calling this function informs the
executor that the currently executing task is about to block the thread,
so the executor is able to hand off any other tasks it has to a new
worker thread before that happens. See the <a href="../index.html#cpu-bound-tasks-and-blocking-code">CPU-bound tasks and blocking
code</a> section for more information.</p>
<p>Be aware that although this function avoids starving other independently
spawned tasks, any other code running concurrently in the same task will
be suspended during the call to <code>block_in_place</code>. This can happen e.g.
when using the <a href="../macro.join.html" title="macro tokio::join"><code>join!</code></a> macro. To avoid this issue, use
<a href="fn.spawn_blocking.html" title="fn tokio::task::spawn_blocking"><code>spawn_blocking</code></a> instead of <code>block_in_place</code>.</p>
<p>Note that this function cannot be used within a <a href="../runtime/struct.Builder.html#method.new_current_thread" title="associated function tokio::runtime::Builder::new_current_thread"><code>current_thread</code></a> runtime
because in this case there are no other worker threads to hand off tasks
to. On the other hand, calling the function outside a runtime is
allowed. In this case, <code>block_in_place</code> just calls the provided closure
normally.</p>
<p>Code running behind <code>block_in_place</code> cannot be cancelled. When you shut
down the executor, it will wait indefinitely for all blocking operations
to finish. You can use <a href="../runtime/struct.Runtime.html#method.shutdown_timeout" title="method tokio::runtime::Runtime::shutdown_timeout"><code>shutdown_timeout</code></a> to stop waiting for them
after a certain timeout. Be aware that this will still not cancel the
tasks — they are simply allowed to keep running after the method
returns.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task;
task::block_in_place(<span class="kw">move </span>|| {
<span class="comment">// do some compute-heavy work or call synchronous code
</span>});</code></pre></div>
<p>Code running inside <code>block_in_place</code> may use <code>block_on</code> to reenter the
async context.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task;
<span class="kw">use </span>tokio::runtime::Handle;
task::block_in_place(<span class="kw">move </span>|| {
Handle::current().block_on(<span class="kw">async move </span>{
<span class="comment">// do something async
</span>});
});</code></pre></div><h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if called from a <a href="../runtime/struct.Builder.html#method.new_current_thread" title="associated function tokio::runtime::Builder::new_current_thread"><code>current_thread</code></a> runtime.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,7 @@
<!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="Returns the `Id` of the currently running task."><title>id in tokio::task - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">id</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">id</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#panics" title="Panics">Panics</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>task</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">task</a></div><h1>Function <span class="fn">id</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tokio/runtime/task/id.rs.html#45-47">Source</a> </span></div><pre class="rust item-decl"><code>pub fn id() -&gt; <a class="struct" href="struct.Id.html" title="struct tokio::task::Id">Id</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returns the <a href="struct.Id.html" title="struct tokio::task::Id"><code>Id</code></a> of the currently running task.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if called from outside a task. Please note that calls
to <code>block_on</code> do not have task IDs, so the method will panic if called from
within a call to <code>block_on</code>. For a version of this function that doesnt
panic, see <a href="fn.try_id.html" title="fn tokio::task::try_id"><code>task::try_id()</code></a>.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,120 @@
<!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="Spawns a new asynchronous task, returning a `JoinHandle` for it."><title>spawn in tokio::task - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">spawn</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">spawn</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#panics" title="Panics">Panics</a></li><li><a href="#using-send-values-from-a-task" title="Using `!Send` values from a task">Using <code>!Send</code> values from a task</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>task</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">task</a></div><h1>Function <span class="fn">spawn</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tokio/task/spawn.rs.html#169-180">Source</a> </span></div><pre class="rust item-decl"><code>pub fn spawn&lt;F&gt;(future: F) -&gt; <a class="struct" href="struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a>&lt;F::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt; <a href="#" class="tooltip" data-notable-ty="JoinHandle&lt;F::Output&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,
F::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Spawns a new asynchronous task, returning a
<a href="struct.JoinHandle.html" title="struct tokio::task::JoinHandle"><code>JoinHandle</code></a> for it.</p>
<p>The provided future will start running in the background immediately
when <code>spawn</code> is called, even if you dont await the returned
<code>JoinHandle</code>.</p>
<p>Spawning a task enables the task to execute concurrently to other tasks. The
spawned task may execute on the current thread, or it may be sent to a
different thread to be executed. The specifics depend on the current
<a href="../runtime/struct.Runtime.html" title="struct tokio::runtime::Runtime"><code>Runtime</code></a> configuration.</p>
<p>It is guaranteed that spawn will not synchronously poll the task being spawned.
This means that calling spawn while holding a lock does not pose a risk of
deadlocking with the spawned task.</p>
<p>There is no guarantee that a spawned task will execute to completion.
When a runtime is shutdown, all outstanding tasks are dropped,
regardless of the lifecycle of that task.</p>
<p>This function must be called from the context of a Tokio runtime. Tasks running on
the Tokio runtime are always inside its context, but you can also enter the context
using the <a href="../runtime/struct.Runtime.html#method.enter" title="method tokio::runtime::Runtime::enter"><code>Runtime::enter</code></a> method.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>In this example, a server is started and <code>spawn</code> is used to start a new task
that processes each received connection.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::{TcpListener, TcpStream};
<span class="kw">use </span>std::io;
<span class="kw">async fn </span>process(socket: TcpStream) {
<span class="comment">// ...
</span>}
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() -&gt; io::Result&lt;()&gt; {
<span class="kw">let </span>listener = TcpListener::bind(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">loop </span>{
<span class="kw">let </span>(socket, <span class="kw">_</span>) = listener.accept().<span class="kw">await</span><span class="question-mark">?</span>;
tokio::spawn(<span class="kw">async move </span>{
<span class="comment">// Process each socket concurrently.
</span>process(socket).<span class="kw">await
</span>});
}
}</code></pre></div>
<p>To run multiple tasks in parallel and receive their results, join
handles can be stored in a vector.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">async fn </span>my_background_op(id: i32) -&gt; String {
<span class="kw">let </span>s = <span class="macro">format!</span>(<span class="string">"Starting background task {}."</span>, id);
<span class="macro">println!</span>(<span class="string">"{}"</span>, s);
s
}
<span class="kw">let </span>ops = <span class="macro">vec!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="kw">let </span><span class="kw-2">mut </span>tasks = Vec::with_capacity(ops.len());
<span class="kw">for </span>op <span class="kw">in </span>ops {
<span class="comment">// This call will make them start running in the background
// immediately.
</span>tasks.push(tokio::spawn(my_background_op(op)));
}
<span class="kw">let </span><span class="kw-2">mut </span>outputs = Vec::with_capacity(tasks.len());
<span class="kw">for </span>task <span class="kw">in </span>tasks {
outputs.push(task.<span class="kw">await</span>.unwrap());
}
<span class="macro">println!</span>(<span class="string">"{:?}"</span>, outputs);</code></pre></div>
<p>This example pushes the tasks to <code>outputs</code> in the order they were
started in. If you do not care about the ordering of the outputs, then
you can also use a <a href="struct.JoinSet.html" title="struct tokio::task::JoinSet"><code>JoinSet</code></a>.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>Panics if called from <strong>outside</strong> of the Tokio runtime.</p>
<h2 id="using-send-values-from-a-task"><a class="doc-anchor" href="#using-send-values-from-a-task">§</a>Using <code>!Send</code> values from a task</h2>
<p>The task supplied to <code>spawn</code> must implement <code>Send</code>. However, it is
possible to <strong>use</strong> <code>!Send</code> values from the task as long as they only
exist between calls to <code>.await</code>.</p>
<p>For example, this will work:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task;
<span class="kw">use </span>std::rc::Rc;
<span class="kw">fn </span>use_rc(rc: Rc&lt;()&gt;) {
<span class="comment">// Do stuff w/ rc
</span>}
tokio::spawn(<span class="kw">async </span>{
<span class="comment">// Force the `Rc` to stay in a scope with no `.await`
</span>{
<span class="kw">let </span>rc = Rc::new(());
use_rc(rc.clone());
}
task::yield_now().<span class="kw">await</span>;
}).<span class="kw">await</span>.unwrap();</code></pre></div>
<p>This will <strong>not</strong> work:</p>
<div class="example-wrap compile_fail"><a href="#" class="tooltip" title="This example deliberately fails to compile"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task;
<span class="kw">use </span>std::rc::Rc;
<span class="kw">fn </span>use_rc(rc: Rc&lt;()&gt;) {
<span class="comment">// Do stuff w/ rc
</span>}
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
tokio::spawn(<span class="kw">async </span>{
<span class="kw">let </span>rc = Rc::new(());
task::yield_now().<span class="kw">await</span>;
use_rc(rc.clone());
}).<span class="kw">await</span>.unwrap();
}</code></pre></div>
<p>Holding on to a <code>!Send</code> value across calls to <code>.await</code> will result in
an unfriendly compile error message similar to:</p>
<div class="example-wrap"><pre class="language-text"><code>`[... some type ...]` cannot be sent between threads safely</code></pre></div>
<p>or:</p>
<div class="example-wrap"><pre class="language-text"><code>error[E0391]: cycle detected when processing `main`</code></pre></div></div></details><script type="text/json" id="notable-traits-data">{"JoinHandle<F::Output>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.JoinHandle.html\" title=\"struct tokio::task::JoinHandle\">JoinHandle</a>&lt;T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;T&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.JoinHandle.html\" title=\"struct tokio::task::JoinHandle\">JoinHandle</a>&lt;T&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"enum\" href=\"https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html\" title=\"enum core::result::Result\">Result</a>&lt;T, <a class=\"struct\" href=\"struct.JoinError.html\" title=\"struct tokio::task::JoinError\">JoinError</a>&gt;;</div>"}</script></section></div></main></body></html>

View File

@@ -0,0 +1,88 @@
<!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="Runs the provided closure on a thread where blocking is acceptable."><title>spawn_blocking in tokio::task - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">spawn_blocking</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">spawn_<wbr>blocking</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#related-apis-and-patterns-for-bridging-asynchronous-and-blocking-code" title="Related APIs and patterns for bridging asynchronous and blocking code">Related APIs and patterns for bridging asynchronous and blocking code</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>task</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">task</a></div><h1>Function <span class="fn">spawn_<wbr>blocking</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tokio/task/blocking.rs.html#205-211">Source</a> </span></div><pre class="rust item-decl"><code>pub fn spawn_blocking&lt;F, R&gt;(f: F) -&gt; <a class="struct" href="struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a>&lt;R&gt; <a href="#" class="tooltip" data-notable-ty="JoinHandle&lt;R&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -&gt; R + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,
R: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Runs the provided closure on a thread where blocking is acceptable.</p>
<p>In general, issuing a blocking call or performing a lot of compute in a
future without yielding is problematic, as it may prevent the executor from
driving other futures forward. This function runs the provided closure on a
thread dedicated to blocking operations. See the <a href="../index.html#cpu-bound-tasks-and-blocking-code">CPU-bound tasks and
blocking code</a> section for more information.</p>
<p>Tokio will spawn more blocking threads when they are requested through this
function until the upper limit configured on the <a href="../runtime/struct.Builder.html" title="struct tokio::runtime::Builder"><code>Builder</code></a> is reached.
After reaching the upper limit, the tasks are put in a queue.
The thread limit is very large by default, because <code>spawn_blocking</code> is often
used for various kinds of IO operations that cannot be performed
asynchronously. When you run CPU-bound code using <code>spawn_blocking</code>, you
should keep this large upper limit in mind. When running many CPU-bound
computations, a semaphore or some other synchronization primitive should be
used to limit the number of computation executed in parallel. Specialized
CPU-bound executors, such as <a href="https://docs.rs/rayon">rayon</a>, may also be a good fit.</p>
<p>This function is intended for non-async operations that eventually finish on
their own. If you want to spawn an ordinary thread, you should use
<a href="https://doc.rust-lang.org/1.93.1/std/thread/functions/fn.spawn.html" title="fn std::thread::functions::spawn"><code>thread::spawn</code></a> instead.</p>
<p>Be aware that tasks spawned using <code>spawn_blocking</code> cannot be aborted
because they are not async. If you call <a href="struct.JoinHandle.html#method.abort" title="method tokio::task::JoinHandle::abort"><code>abort</code></a> on a <code>spawn_blocking</code>
task, then this <em>will not have any effect</em>, and the task will continue
running normally. The exception is if the task has not started running
yet; in that case, calling <code>abort</code> may prevent the task from starting.</p>
<p>When you shut down the executor, it will attempt to <code>abort</code> all tasks
including <code>spawn_blocking</code> tasks. However, <code>spawn_blocking</code> tasks
cannot be aborted once they start running, which means that runtime
shutdown will wait indefinitely for all started <code>spawn_blocking</code> to
finish running. You can use <a href="../runtime/struct.Runtime.html#method.shutdown_timeout" title="method tokio::runtime::Runtime::shutdown_timeout"><code>shutdown_timeout</code></a> to stop waiting for
them after a certain timeout. Be aware that this will still not cancel
the tasks — they are simply allowed to keep running after the method
returns. It is possible for a blocking task to be cancelled if it has
not yet started running, but this is not guaranteed.</p>
<p>Note that if you are using the single threaded runtime, this function will
still spawn additional threads for blocking operations. The current-thread
schedulers single thread is only used for asynchronous code.</p>
<h2 id="related-apis-and-patterns-for-bridging-asynchronous-and-blocking-code"><a class="doc-anchor" href="#related-apis-and-patterns-for-bridging-asynchronous-and-blocking-code">§</a>Related APIs and patterns for bridging asynchronous and blocking code</h2>
<p>In simple cases, it is sufficient to have the closure accept input
parameters at creation time and return a single value (or struct/tuple, etc.).</p>
<p>For more complex situations in which it is desirable to stream data to or from
the synchronous context, the <a href="../sync/mpsc/index.html" title="mod tokio::sync::mpsc"><code>mpsc channel</code></a> has <code>blocking_send</code> and
<code>blocking_recv</code> methods for use in non-async code such as the thread created
by <code>spawn_blocking</code>.</p>
<p>Another option is <a href="https://docs.rs/tokio-util/latest/tokio_util/io/struct.SyncIoBridge.html"><code>SyncIoBridge</code></a> for cases where the synchronous context
is operating on byte streams. For example, you might use an asynchronous
HTTP client such as <a href="https://docs.rs/hyper">hyper</a> to fetch data, but perform complex parsing
of the payload body using a library written for synchronous I/O.</p>
<p>Finally, see also <a href="https://tokio.rs/tokio/topics/bridging">Bridging with sync code</a> for discussions
around the opposite case of using Tokio as part of a larger synchronous
codebase.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Pass an input value and receive result of computation:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task;
<span class="comment">// Initial input
</span><span class="kw">let </span><span class="kw-2">mut </span>v = <span class="string">"Hello, "</span>.to_string();
<span class="kw">let </span>res = task::spawn_blocking(<span class="kw">move </span>|| {
<span class="comment">// Stand-in for compute-heavy work or using synchronous APIs
</span>v.push_str(<span class="string">"world"</span>);
<span class="comment">// Pass ownership of the value back to the asynchronous context
</span>v
}).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="comment">// `res` is the value returned from the thread
</span><span class="macro">assert_eq!</span>(res.as_str(), <span class="string">"Hello, world"</span>);</code></pre></div>
<p>Use a channel:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task;
<span class="kw">use </span>tokio::sync::mpsc;
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx) = mpsc::channel(<span class="number">2</span>);
<span class="kw">let </span>start = <span class="number">5</span>;
<span class="kw">let </span>worker = task::spawn_blocking(<span class="kw">move </span>|| {
<span class="kw">for </span>x <span class="kw">in </span><span class="number">0</span>..<span class="number">10 </span>{
<span class="comment">// Stand in for complex computation
</span>tx.blocking_send(start + x).unwrap();
}
});
<span class="kw">let </span><span class="kw-2">mut </span>acc = <span class="number">0</span>;
<span class="kw">while let </span><span class="prelude-val">Some</span>(v) = rx.recv().<span class="kw">await </span>{
acc += v;
}
<span class="macro">assert_eq!</span>(acc, <span class="number">95</span>);
worker.<span class="kw">await</span>.unwrap();</code></pre></div></div></details><script type="text/json" id="notable-traits-data">{"JoinHandle<R>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.JoinHandle.html\" title=\"struct tokio::task::JoinHandle\">JoinHandle</a>&lt;T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;T&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.JoinHandle.html\" title=\"struct tokio::task::JoinHandle\">JoinHandle</a>&lt;T&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"enum\" href=\"https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html\" title=\"enum core::result::Result\">Result</a>&lt;T, <a class=\"struct\" href=\"struct.JoinError.html\" title=\"struct tokio::task::JoinError\">JoinError</a>&gt;;</div>"}</script></section></div></main></body></html>

View File

@@ -0,0 +1,46 @@
<!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="Spawns a `!Send` future on the current `LocalSet` or `LocalRuntime`."><title>spawn_local in tokio::task - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">spawn_local</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">spawn_<wbr>local</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#panics" title="Panics">Panics</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>task</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">task</a></div><h1>Function <span class="fn">spawn_<wbr>local</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tokio/task/local.rs.html#399-410">Source</a> </span></div><pre class="rust item-decl"><code>pub fn spawn_local&lt;F&gt;(future: F) -&gt; <a class="struct" href="struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a>&lt;F::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt; <a href="#" class="tooltip" data-notable-ty="JoinHandle&lt;F::Output&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + 'static,
F::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>: 'static,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Spawns a <code>!Send</code> future on the current <a href="struct.LocalSet.html" title="struct tokio::task::LocalSet"><code>LocalSet</code></a> or <a href="struct@crate::runtime::LocalRuntime"><code>LocalRuntime</code></a>.</p>
<p>This is possible when either using one of these types
explicitly, or (with <code>tokio_unstable</code>) by opting to use the
<code>"local"</code> runtime flavor in <code>tokio::main</code>:</p>
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested"></a><pre class="rust rust-example-rendered"><code><span class="attr">#[tokio::main(flavor = <span class="string">"local"</span>)]</span></code></pre></div>
<p>The spawned future will run on the same thread that called <code>spawn_local</code>.</p>
<p>The provided future will start running in the background immediately
when <code>spawn_local</code> is called, even if you dont await the returned
<code>JoinHandle</code>.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if called outside of a <a href="struct.LocalSet.html" title="struct tokio::task::LocalSet"><code>LocalSet</code></a> or <a href="struct@crate::runtime::LocalRuntime"><code>LocalRuntime</code></a>.</p>
<p>Note that if <a href="fn.spawn.html" title="fn tokio::task::spawn"><code>tokio::spawn</code></a> is used from within a <code>LocalSet</code>, the
resulting new task will <em>not</em> be inside the <code>LocalSet</code>, so you must use
<code>spawn_local</code> if you want to stay within the <code>LocalSet</code>.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>With <code>LocalSet</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::rc::Rc;
<span class="kw">use </span>tokio::task;
<span class="kw">let </span>nonsend_data = Rc::new(<span class="string">"my nonsend data..."</span>);
<span class="kw">let </span>local = task::LocalSet::new();
<span class="comment">// Run the local task set.
</span>local.run_until(<span class="kw">async move </span>{
<span class="kw">let </span>nonsend_data = nonsend_data.clone();
task::spawn_local(<span class="kw">async move </span>{
<span class="macro">println!</span>(<span class="string">"{}"</span>, nonsend_data);
<span class="comment">// ...
</span>}).<span class="kw">await</span>.unwrap();
}).<span class="kw">await</span>;</code></pre></div>
<p>With local runtime flavor (<a href="../../tokio/index.html#unstable-features">Unstable API</a> only).</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[tokio::main(flavor = <span class="string">"local"</span>)]
</span><span class="kw">async fn </span>main() {
<span class="kw">let </span>join = tokio::task::spawn_local(<span class="kw">async </span>{
<span class="macro">println!</span>(<span class="string">"my nonsend data..."</span>)
});
join.<span class="kw">await</span>.unwrap()
}
</code></pre></div></div></details><script type="text/json" id="notable-traits-data">{"JoinHandle<F::Output>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.JoinHandle.html\" title=\"struct tokio::task::JoinHandle\">JoinHandle</a>&lt;T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;T&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.JoinHandle.html\" title=\"struct tokio::task::JoinHandle\">JoinHandle</a>&lt;T&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"enum\" href=\"https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html\" title=\"enum core::result::Result\">Result</a>&lt;T, <a class=\"struct\" href=\"struct.JoinError.html\" title=\"struct tokio::task::JoinError\">JoinError</a>&gt;;</div>"}</script></section></div></main></body></html>

View File

@@ -0,0 +1,6 @@
<!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="Returns the `Id` of the currently running task, or `None` if called outside of a task."><title>try_id in tokio::task - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">try_id</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>task</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">task</a></div><h1>Function <span class="fn">try_id</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tokio/runtime/task/id.rs.html#58-60">Source</a> </span></div><pre class="rust item-decl"><code>pub fn try_id() -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Id.html" title="struct tokio::task::Id">Id</a>&gt;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returns the <a href="struct.Id.html" title="struct tokio::task::Id"><code>Id</code></a> of the currently running task, or <code>None</code> if called outside
of a task.</p>
<p>This function is similar to <a href="fn.id.html" title="fn tokio::task::id"><code>task::id()</code></a>, except
that it returns <code>None</code> rather than panicking if called outside of a task
context.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,24 @@
<!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="Yields execution back to the Tokio runtime."><title>yield_now in tokio::task - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">yield_now</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">yield_<wbr>now</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#non-guarantees" title="Non-guarantees">Non-guarantees</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>task</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">task</a></div><h1>Function <span class="fn">yield_<wbr>now</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tokio/task/yield_now.rs.html#39-64">Source</a> </span></div><pre class="rust item-decl"><code>pub async fn yield_now()</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Yields execution back to the Tokio runtime.</p>
<p>A task yields by awaiting on <code>yield_now()</code>, and may resume when that future
completes (with no output.) The current task will be re-added as a pending
task at the <em>back</em> of the pending queue. Any other pending tasks will be
scheduled. No other waking is required for the task to continue.</p>
<p>See also the usage example in the <a href="index.html#yield_now">task module</a>.</p>
<h3 id="non-guarantees"><a class="doc-anchor" href="#non-guarantees">§</a>Non-guarantees</h3>
<p>This function may not yield all the way up to the executor if there are any
special combinators above it in the call stack. For example, if a
<a href="../macro.select.html" title="macro tokio::select"><code>tokio::select!</code></a> has another branch complete during the same poll as the
<code>yield_now()</code>, then the yield is not propagated all the way up to the
runtime.</p>
<p>It is generally not guaranteed that the runtime behaves like you expect it
to when deciding which task to schedule next after a call to <code>yield_now()</code>.
In particular, the runtime may choose to poll the task that just ran
<code>yield_now()</code> again immediately without polling any other tasks first. For
example, the runtime will not drive the IO driver between every poll of a
task, and this could result in the runtime polling the current task again
immediately even if there is another task that could make progress if that
other task is waiting for a notification from the IO driver.</p>
<p>In general, changes to the order in which the runtime polls tasks is not
considered a breaking change, and your program should be correct no matter
which order the runtime polls your tasks in.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,3 @@
<!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="Task-related futures."><title>tokio::task::futures - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module futures</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module futures</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In tokio::<wbr>task</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">task</a></div><h1>Module <span>futures</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/tokio/task/mod.rs.html#328">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Task-related futures.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.TaskLocalFuture.html" title="struct tokio::task::futures::TaskLocalFuture">Task<wbr>Local<wbr>Future</a></dt><dd>A future that sets a value <code>T</code> of a task local for the future <code>F</code> during
its execution.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"struct":["TaskLocalFuture"]};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,188 @@
<!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="Asynchronous green-threads."><title>tokio::task - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module task</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module task</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#what-are-tasks" title="What are Tasks?">What are Tasks?</a></li><li><a href="#working-with-tasks" title="Working with Tasks">Working with Tasks</a><ul><li><a href="#spawning" title="Spawning">Spawning</a></li><li><a href="#blocking-and-yielding" title="Blocking and Yielding">Blocking and Yielding</a></li></ul></li></ul><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate tokio</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a></div><h1>Module <span>task</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tokio/task/mod.rs.html#1-335">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Asynchronous green-threads.</p>
<h3 id="what-are-tasks"><a class="doc-anchor" href="#what-are-tasks">§</a>What are Tasks?</h3>
<p>A <em>task</em> is a light weight, non-blocking unit of execution. A task is similar
to an OS thread, but rather than being managed by the OS scheduler, they are
managed by the <a href="../runtime/index.html" title="mod tokio::runtime">Tokio runtime</a>. Another name for this general pattern is
<a href="https://en.wikipedia.org/wiki/Green_threads">green threads</a>. If you are familiar with <a href="https://tour.golang.org/concurrency/1">Gos goroutines</a>, <a href="https://kotlinlang.org/docs/reference/coroutines-overview.html">Kotlins
coroutines</a>, or <a href="http://erlang.org/doc/getting_started/conc_prog.html#processes">Erlangs processes</a>, you can think of Tokios tasks as
something similar.</p>
<p>Key points about tasks include:</p>
<ul>
<li>
<p>Tasks are <strong>light weight</strong>. Because tasks are scheduled by the Tokio
runtime rather than the operating system, creating new tasks or switching
between tasks does not require a context switch and has fairly low
overhead. Creating, running, and destroying large numbers of tasks is
quite cheap, especially compared to OS threads.</p>
</li>
<li>
<p>Tasks are scheduled <strong>cooperatively</strong>. Most operating systems implement
<em>preemptive multitasking</em>. This is a scheduling technique where the
operating system allows each thread to run for a period of time, and then
<em>preempts</em> it, temporarily pausing that thread and switching to another.
Tasks, on the other hand, implement <em>cooperative multitasking</em>. In
cooperative multitasking, a task is allowed to run until it <em>yields</em>,
indicating to the Tokio runtimes scheduler that it cannot currently
continue executing. When a task yields, the Tokio runtime switches to
executing the next task.</p>
</li>
<li>
<p>Tasks are <strong>non-blocking</strong>. Typically, when an OS thread performs I/O or
must synchronize with another thread, it <em>blocks</em>, allowing the OS to
schedule another thread. When a task cannot continue executing, it must
yield instead, allowing the Tokio runtime to schedule another task. Tasks
should generally not perform system calls or other operations that could
block a thread, as this would prevent other tasks running on the same
thread from executing as well. Instead, this module provides APIs for
running blocking operations in an asynchronous context.</p>
</li>
</ul>
<h3 id="working-with-tasks"><a class="doc-anchor" href="#working-with-tasks">§</a>Working with Tasks</h3>
<p>This module provides the following APIs for working with tasks:</p>
<h4 id="spawning"><a class="doc-anchor" href="#spawning">§</a>Spawning</h4>
<p>Perhaps the most important function in this module is <a href="fn.spawn.html" title="fn tokio::task::spawn"><code>task::spawn</code></a>. This
function can be thought of as an async equivalent to the standard librarys
<a href="https://doc.rust-lang.org/1.93.1/std/thread/functions/fn.spawn.html" title="fn std::thread::functions::spawn"><code>thread::spawn</code></a>. It takes an <code>async</code> block or other
<a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future">future</a>, and creates a new task to run that work concurrently:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task;
task::spawn(<span class="kw">async </span>{
<span class="comment">// perform some work here...
</span>});</code></pre></div>
<p>Like <a href="https://doc.rust-lang.org/1.93.1/std/thread/functions/fn.spawn.html" title="fn std::thread::functions::spawn"><code>std::thread::spawn</code></a>, <code>task::spawn</code> returns a <a href="struct.JoinHandle.html" title="struct tokio::task::JoinHandle"><code>JoinHandle</code></a> struct.
A <code>JoinHandle</code> is itself a future which may be used to await the output of
the spawned task. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task;
<span class="kw">let </span>join = task::spawn(<span class="kw">async </span>{
<span class="comment">// ...
</span><span class="string">"hello world!"
</span>});
<span class="comment">// ...
// Await the result of the spawned task.
</span><span class="kw">let </span>result = join.<span class="kw">await</span><span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(result, <span class="string">"hello world!"</span>);</code></pre></div>
<p>Again, like <code>std::thread</code>s <a href="https://doc.rust-lang.org/1.93.1/std/thread/join_handle/struct.JoinHandle.html" title="struct std::thread::join_handle::JoinHandle"><code>JoinHandle</code> type</a>, if the spawned
task panics, awaiting its <code>JoinHandle</code> will return a <a href="struct.JoinError.html" title="struct tokio::task::JoinError"><code>JoinError</code></a>. For
example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task;
<span class="kw">let </span>join = task::spawn(<span class="kw">async </span>{
<span class="macro">panic!</span>(<span class="string">"something bad happened!"</span>)
});
<span class="comment">// The returned result indicates that the task failed.
</span><span class="macro">assert!</span>(join.<span class="kw">await</span>.is_err());</code></pre></div>
<p><code>spawn</code>, <code>JoinHandle</code>, and <code>JoinError</code> are present when the “rt”
feature flag is enabled.</p>
<h5 id="cancellation"><a class="doc-anchor" href="#cancellation">§</a>Cancellation</h5>
<p>Spawned tasks may be cancelled using the <a href="struct.JoinHandle.html#method.abort" title="method tokio::task::JoinHandle::abort"><code>JoinHandle::abort</code></a> or
<a href="struct.AbortHandle.html#method.abort" title="method tokio::task::AbortHandle::abort"><code>AbortHandle::abort</code></a> methods. When one of these methods are called, the
task is signalled to shut down next time it yields at an <code>.await</code> point. If
the task is already idle, then it will be shut down as soon as possible
without running again before being shut down. Additionally, shutting down a
Tokio runtime (e.g. by returning from <code>#[tokio::main]</code>) immediately cancels
all tasks on it.</p>
<p>When tasks are shut down, it will stop running at whichever <code>.await</code> it has
yielded at. All local variables are destroyed by running their destructor.
Once shutdown has completed, awaiting the <a href="struct.JoinHandle.html" title="struct tokio::task::JoinHandle"><code>JoinHandle</code></a> will fail with a
<a href="struct.JoinError.html#method.is_cancelled" title="method tokio::task::JoinError::is_cancelled">cancelled error</a>.</p>
<p>Note that aborting a task does not guarantee that it fails with a cancelled
error, since it may complete normally first. For example, if the task does
not yield to the runtime at any point between the call to <code>abort</code> and the
end of the task, then the <a href="struct.JoinHandle.html" title="struct tokio::task::JoinHandle"><code>JoinHandle</code></a> will instead report that the task
exited normally.</p>
<p>Be aware that tasks spawned using <a href="fn.spawn_blocking.html" title="fn tokio::task::spawn_blocking"><code>spawn_blocking</code></a> cannot be aborted
because they are not async. If you call <code>abort</code> on a <code>spawn_blocking</code>
task, then this <em>will not have any effect</em>, and the task will continue
running normally. The exception is if the task has not started running
yet; in that case, calling <code>abort</code> may prevent the task from starting.</p>
<p>Be aware that calls to <a href="struct.JoinHandle.html#method.abort" title="method tokio::task::JoinHandle::abort"><code>JoinHandle::abort</code></a> just schedule the task for
cancellation, and will return before the cancellation has completed. To wait
for cancellation to complete, wait for the task to finish by awaiting the
<a href="struct.JoinHandle.html" title="struct tokio::task::JoinHandle"><code>JoinHandle</code></a>. Similarly, the <a href="struct.JoinHandle.html#method.is_finished" title="method tokio::task::JoinHandle::is_finished"><code>JoinHandle::is_finished</code></a> method does not
return <code>true</code> until the cancellation has finished.</p>
<p>Calling <a href="struct.JoinHandle.html#method.abort" title="method tokio::task::JoinHandle::abort"><code>JoinHandle::abort</code></a> multiple times has the same effect as calling
it once.</p>
<p>Tokio also provides an <a href="struct.AbortHandle.html" title="struct tokio::task::AbortHandle"><code>AbortHandle</code></a>, which is like the <a href="struct.JoinHandle.html" title="struct tokio::task::JoinHandle"><code>JoinHandle</code></a>,
except that it does not provide a mechanism to wait for the task to finish.
Each task can only have one <a href="struct.JoinHandle.html" title="struct tokio::task::JoinHandle"><code>JoinHandle</code></a>, but it can have more than one
<a href="struct.AbortHandle.html" title="struct tokio::task::AbortHandle"><code>AbortHandle</code></a>.</p>
<h4 id="blocking-and-yielding"><a class="doc-anchor" href="#blocking-and-yielding">§</a>Blocking and Yielding</h4>
<p>As we discussed above, code running in asynchronous tasks should not perform
operations that can block. A blocking operation performed in a task running
on a thread that is also running other tasks would block the entire thread,
preventing other tasks from running.</p>
<p>Instead, Tokio provides two APIs for running blocking operations in an
asynchronous context: <a href="fn.spawn_blocking.html" title="fn tokio::task::spawn_blocking"><code>task::spawn_blocking</code></a> and <a href="fn.block_in_place.html" title="fn tokio::task::block_in_place"><code>task::block_in_place</code></a>.</p>
<p>Be aware that if you call a non-async method from async code, that non-async
method is still inside the asynchronous context, so you should also avoid
blocking operations there. This includes destructors of objects destroyed in
async code.</p>
<h5 id="spawn_blocking"><a class="doc-anchor" href="#spawn_blocking">§</a><code>spawn_blocking</code></h5>
<p>The <code>task::spawn_blocking</code> function is similar to the <code>task::spawn</code> function
discussed in the previous section, but rather than spawning an
<em>non-blocking</em> future on the Tokio runtime, it instead spawns a
<em>blocking</em> function on a dedicated thread pool for blocking tasks. For
example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task;
task::spawn_blocking(|| {
<span class="comment">// do some compute-heavy work or call synchronous code
</span>});</code></pre></div>
<p>Just like <code>task::spawn</code>, <code>task::spawn_blocking</code> returns a <code>JoinHandle</code>
which we can use to await the result of the blocking operation:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>join = task::spawn_blocking(|| {
<span class="comment">// do some compute-heavy work or call synchronous code
</span><span class="string">"blocking completed"
</span>});
<span class="kw">let </span>result = join.<span class="kw">await</span><span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(result, <span class="string">"blocking completed"</span>);</code></pre></div><h5 id="block_in_place"><a class="doc-anchor" href="#block_in_place">§</a><code>block_in_place</code></h5>
<p>When using the <a href="../runtime/index.html#threaded-scheduler">multi-threaded runtime</a>, the <a href="fn.block_in_place.html" title="fn tokio::task::block_in_place"><code>task::block_in_place</code></a>
function is also available. Like <code>task::spawn_blocking</code>, this function
allows running a blocking operation from an asynchronous context. Unlike
<code>spawn_blocking</code>, however, <code>block_in_place</code> works by transitioning the
<em>current</em> worker thread to a blocking thread, moving other tasks running on
that thread to another worker thread. This can improve performance by avoiding
context switches.</p>
<p>For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task;
<span class="kw">let </span>result = task::block_in_place(|| {
<span class="comment">// do some compute-heavy work or call synchronous code
</span><span class="string">"blocking completed"
</span>});
<span class="macro">assert_eq!</span>(result, <span class="string">"blocking completed"</span>);</code></pre></div><h5 id="yield_now"><a class="doc-anchor" href="#yield_now">§</a><code>yield_now</code></h5>
<p>In addition, this module provides a <a href="fn.yield_now.html" title="fn tokio::task::yield_now"><code>task::yield_now</code></a> async function
that is analogous to the standard librarys <a href="https://doc.rust-lang.org/1.93.1/std/thread/functions/fn.yield_now.html" title="fn std::thread::functions::yield_now"><code>thread::yield_now</code></a>. Calling
and <code>await</code>ing this function will cause the current task to yield to the
Tokio runtimes scheduler, allowing other tasks to be
scheduled. Eventually, the yielding task will be polled again, allowing it
to execute. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::task;
<span class="kw">async </span>{
task::spawn(<span class="kw">async </span>{
<span class="comment">// ...
</span><span class="macro">println!</span>(<span class="string">"spawned task done!"</span>)
});
<span class="comment">// Yield, allowing the newly-spawned task to execute first.
</span>task::yield_now().<span class="kw">await</span>;
<span class="macro">println!</span>(<span class="string">"main task done!"</span>);
}</code></pre></div></div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="coop/index.html" title="mod tokio::task::coop">coop</a></dt><dd>Utilities for improved cooperative scheduling.</dd><dt><a class="mod" href="futures/index.html" title="mod tokio::task::futures">futures</a></dt><dd>Task-related futures.</dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.AbortHandle.html" title="struct tokio::task::AbortHandle">Abort<wbr>Handle</a></dt><dd>An owned permission to abort a spawned task, without awaiting its completion.</dd><dt><a class="struct" href="struct.Id.html" title="struct tokio::task::Id">Id</a></dt><dd>An opaque ID that uniquely identifies a task relative to all other currently
running tasks.</dd><dt><a class="struct" href="struct.JoinError.html" title="struct tokio::task::JoinError">Join<wbr>Error</a></dt><dd>Task failed to execute to completion.</dd><dt><a class="struct" href="struct.JoinHandle.html" title="struct tokio::task::JoinHandle">Join<wbr>Handle</a></dt><dd>An owned permission to join on a task (await its termination).</dd><dt><a class="struct" href="struct.JoinSet.html" title="struct tokio::task::JoinSet">JoinSet</a></dt><dd>A collection of tasks spawned on a Tokio runtime.</dd><dt><a class="struct" href="struct.LocalEnterGuard.html" title="struct tokio::task::LocalEnterGuard">Local<wbr>Enter<wbr>Guard</a></dt><dd>Context guard for <code>LocalSet</code></dd><dt><a class="struct" href="struct.LocalKey.html" title="struct tokio::task::LocalKey">Local<wbr>Key</a></dt><dd>A key for task-local data.</dd><dt><a class="struct" href="struct.LocalSet.html" title="struct tokio::task::LocalSet">Local<wbr>Set</a></dt><dd>A set of tasks which are executed on the same thread.</dd></dl><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.block_in_place.html" title="fn tokio::task::block_in_place">block_<wbr>in_<wbr>place</a></dt><dd>Runs the provided blocking function on the current thread without
blocking the executor.</dd><dt><a class="fn" href="fn.id.html" title="fn tokio::task::id">id</a></dt><dd>Returns the <a href="struct.Id.html" title="struct tokio::task::Id"><code>Id</code></a> of the currently running task.</dd><dt><a class="fn" href="fn.spawn.html" title="fn tokio::task::spawn">spawn</a></dt><dd>Spawns a new asynchronous task, returning a
<a href="struct.JoinHandle.html" title="struct tokio::task::JoinHandle"><code>JoinHandle</code></a> for it.</dd><dt><a class="fn" href="fn.spawn_blocking.html" title="fn tokio::task::spawn_blocking">spawn_<wbr>blocking</a></dt><dd>Runs the provided closure on a thread where blocking is acceptable.</dd><dt><a class="fn" href="fn.spawn_local.html" title="fn tokio::task::spawn_local">spawn_<wbr>local</a></dt><dd>Spawns a <code>!Send</code> future on the current <a href="struct.LocalSet.html" title="struct tokio::task::LocalSet"><code>LocalSet</code></a> or <a href="struct@crate::runtime::LocalRuntime"><code>LocalRuntime</code></a>.</dd><dt><a class="fn" href="fn.try_id.html" title="fn tokio::task::try_id">try_id</a></dt><dd>Returns the <a href="struct.Id.html" title="struct tokio::task::Id"><code>Id</code></a> of the currently running task, or <code>None</code> if called outside
of a task.</dd><dt><a class="fn" href="fn.yield_now.html" title="fn tokio::task::yield_now">yield_<wbr>now</a></dt><dd>Yields execution back to the Tokio runtime.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/task/struct.JoinSet.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/task/struct.JoinSet.html">../../../tokio/task/struct.JoinSet.html</a>...</p>
<script>location.replace("../../../tokio/task/struct.JoinSet.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/task/fn.spawn_local.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/task/fn.spawn_local.html">../../../tokio/task/fn.spawn_local.html</a>...</p>
<script>location.replace("../../../tokio/task/fn.spawn_local.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/task/struct.LocalEnterGuard.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/task/struct.LocalEnterGuard.html">../../../tokio/task/struct.LocalEnterGuard.html</a>...</p>
<script>location.replace("../../../tokio/task/struct.LocalEnterGuard.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/task/struct.LocalSet.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/task/struct.LocalSet.html">../../../tokio/task/struct.LocalSet.html</a>...</p>
<script>location.replace("../../../tokio/task/struct.LocalSet.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"fn":["block_in_place","id","spawn","spawn_blocking","spawn_local","try_id","yield_now"],"mod":["coop","futures"],"struct":["AbortHandle","Id","JoinError","JoinHandle","JoinSet","LocalEnterGuard","LocalKey","LocalSet"]};

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/task/fn.spawn.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/task/fn.spawn.html">../../../tokio/task/fn.spawn.html</a>...</p>
<script>location.replace("../../../tokio/task/fn.spawn.html" + location.search + location.hash);</script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/task/struct.LocalKey.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/task/struct.LocalKey.html">../../../tokio/task/struct.LocalKey.html</a>...</p>
<script>location.replace("../../../tokio/task/struct.LocalKey.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/task/futures/struct.TaskLocalFuture.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/task/futures/struct.TaskLocalFuture.html">../../../tokio/task/futures/struct.TaskLocalFuture.html</a>...</p>
<script>location.replace("../../../tokio/task/futures/struct.TaskLocalFuture.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/task/fn.yield_now.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/task/fn.yield_now.html">../../../tokio/task/fn.yield_now.html</a>...</p>
<script>location.replace("../../../tokio/task/fn.yield_now.html" + location.search + location.hash);</script>
</body>
</html>