mirror of
https://github.com/NotAShelf/mpvrc.git
synced 2026-04-18 16:49:53 +00:00
deploy: de38ae62916547ad097c066f94a32e9ba7790eeb
This commit is contained in:
commit
9a86359447
28502 changed files with 1261284 additions and 0 deletions
11
tokio/runtime/builder/struct.Builder.html
Normal file
11
tokio/runtime/builder/struct.Builder.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/runtime/struct.Builder.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/runtime/struct.Builder.html">../../../tokio/runtime/struct.Builder.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/runtime/struct.Builder.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
19
tokio/runtime/enum.RuntimeFlavor.html
Normal file
19
tokio/runtime/enum.RuntimeFlavor.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<!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="The flavor of a `Runtime`."><title>RuntimeFlavor in tokio::runtime - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.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" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.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.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc enum"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.42.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Runtime<wbr>Flavor</a></h2><h3><a href="#variants">Variants</a></h3><ul class="block variant"><li><a href="#variant.CurrentThread" title="CurrentThread">CurrentThread</a></li><li><a href="#variant.MultiThread" title="MultiThread">MultiThread</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Debug-for-RuntimeFlavor" title="Debug">Debug</a></li><li><a href="#impl-Eq-for-RuntimeFlavor" title="Eq">Eq</a></li><li><a href="#impl-PartialEq-for-RuntimeFlavor" title="PartialEq">PartialEq</a></li><li><a href="#impl-StructuralPartialEq-for-RuntimeFlavor" title="StructuralPartialEq">StructuralPartialEq</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-RuntimeFlavor" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-RuntimeFlavor" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-RuntimeFlavor" title="Send">Send</a></li><li><a href="#impl-Sync-for-RuntimeFlavor" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-RuntimeFlavor" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-RuntimeFlavor" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow<T>">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut<T>">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T" title="From<T>">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into<U>">Into<U></a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom<U>">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto<U>">TryInto<U></a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>runtime</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">runtime</a></span><h1>Enum <span class="enum">RuntimeFlavor</span><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/runtime.rs.html#115-124">Source</a> </span></div><pre class="rust item-decl"><code><div class="code-attribute">#[non_exhaustive]</div>pub enum RuntimeFlavor {
|
||||
CurrentThread,
|
||||
MultiThread,
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The flavor of a <code>Runtime</code>.</p>
|
||||
<p>This is the return type for <a href="struct.Handle.html#method.runtime_flavor" title="method tokio::runtime::Handle::runtime_flavor"><code>Handle::runtime_flavor</code></a>.</p>
|
||||
</div></details><h2 id="variants" class="variants section-header">Variants (Non-exhaustive)<a href="#variants" class="anchor">§</a></h2><details class="toggle non-exhaustive"><summary class="hideme"><span>This enum is marked as non-exhaustive</span></summary><div class="docblock">Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.</div></details><div class="variants"><section id="variant.CurrentThread" class="variant"><a href="#variant.CurrentThread" class="anchor">§</a><h3 class="code-header">CurrentThread</h3></section><div class="docblock"><p>The flavor that executes all tasks on the current thread.</p>
|
||||
</div><section id="variant.MultiThread" class="variant"><a href="#variant.MultiThread" class="anchor">§</a><h3 class="code-header">MultiThread</h3></section><div class="docblock"><p>The flavor that executes tasks across multiple threads.</p>
|
||||
</div></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-RuntimeFlavor" class="impl"><a class="src rightside" href="../../src/tokio/runtime/runtime.rs.html#113">Source</a><a href="#impl-Debug-for-RuntimeFlavor" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="enum" href="enum.RuntimeFlavor.html" title="enum tokio::runtime::RuntimeFlavor">RuntimeFlavor</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../../src/tokio/runtime/runtime.rs.html#113">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialEq-for-RuntimeFlavor" class="impl"><a class="src rightside" href="../../src/tokio/runtime/runtime.rs.html#113">Source</a><a href="#impl-PartialEq-for-RuntimeFlavor" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> for <a class="enum" href="enum.RuntimeFlavor.html" title="enum tokio::runtime::RuntimeFlavor">RuntimeFlavor</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl"><a class="src rightside" href="../../src/tokio/runtime/runtime.rs.html#113">Source</a><a href="#method.eq" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&self, other: &<a class="enum" href="enum.RuntimeFlavor.html" title="enum tokio::runtime::RuntimeFlavor">RuntimeFlavor</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>.</div></details><details class="toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.84.1/src/core/cmp.rs.html#261">Source</a></span><a href="#method.ne" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&Rhs</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests for <code>!=</code>. The default implementation is almost always sufficient,
|
||||
and should not be overridden without very good reason.</div></details></div></details><section id="impl-Eq-for-RuntimeFlavor" class="impl"><a class="src rightside" href="../../src/tokio/runtime/runtime.rs.html#113">Source</a><a href="#impl-Eq-for-RuntimeFlavor" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="enum" href="enum.RuntimeFlavor.html" title="enum tokio::runtime::RuntimeFlavor">RuntimeFlavor</a></h3></section><section id="impl-StructuralPartialEq-for-RuntimeFlavor" class="impl"><a class="src rightside" href="../../src/tokio/runtime/runtime.rs.html#113">Source</a><a href="#impl-StructuralPartialEq-for-RuntimeFlavor" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.StructuralPartialEq.html" title="trait core::marker::StructuralPartialEq">StructuralPartialEq</a> for <a class="enum" href="enum.RuntimeFlavor.html" title="enum tokio::runtime::RuntimeFlavor">RuntimeFlavor</a></h3></section></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-RuntimeFlavor" class="impl"><a href="#impl-Freeze-for-RuntimeFlavor" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="enum" href="enum.RuntimeFlavor.html" title="enum tokio::runtime::RuntimeFlavor">RuntimeFlavor</a></h3></section><section id="impl-RefUnwindSafe-for-RuntimeFlavor" class="impl"><a href="#impl-RefUnwindSafe-for-RuntimeFlavor" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="enum" href="enum.RuntimeFlavor.html" title="enum tokio::runtime::RuntimeFlavor">RuntimeFlavor</a></h3></section><section id="impl-Send-for-RuntimeFlavor" class="impl"><a href="#impl-Send-for-RuntimeFlavor" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="enum" href="enum.RuntimeFlavor.html" title="enum tokio::runtime::RuntimeFlavor">RuntimeFlavor</a></h3></section><section id="impl-Sync-for-RuntimeFlavor" class="impl"><a href="#impl-Sync-for-RuntimeFlavor" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="enum" href="enum.RuntimeFlavor.html" title="enum tokio::runtime::RuntimeFlavor">RuntimeFlavor</a></h3></section><section id="impl-Unpin-for-RuntimeFlavor" class="impl"><a href="#impl-Unpin-for-RuntimeFlavor" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="enum" href="enum.RuntimeFlavor.html" title="enum tokio::runtime::RuntimeFlavor">RuntimeFlavor</a></h3></section><section id="impl-UnwindSafe-for-RuntimeFlavor" class="impl"><a href="#impl-UnwindSafe-for-RuntimeFlavor" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="enum" href="enum.RuntimeFlavor.html" title="enum tokio::runtime::RuntimeFlavor">RuntimeFlavor</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#209">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#211">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#217">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#218">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#765">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#768">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#748-750">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#758">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
||||
<p>That is, this conversion is whatever the implementation of
|
||||
<code><a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#805-807">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#809">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#812">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#790-792">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#794">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#797">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>
|
||||
11
tokio/runtime/handle/struct.EnterGuard.html
Normal file
11
tokio/runtime/handle/struct.EnterGuard.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/runtime/struct.EnterGuard.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/runtime/struct.EnterGuard.html">../../../tokio/runtime/struct.EnterGuard.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/runtime/struct.EnterGuard.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tokio/runtime/handle/struct.Handle.html
Normal file
11
tokio/runtime/handle/struct.Handle.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/runtime/struct.Handle.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/runtime/struct.Handle.html">../../../tokio/runtime/struct.Handle.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/runtime/struct.Handle.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tokio/runtime/handle/struct.TryCurrentError.html
Normal file
11
tokio/runtime/handle/struct.TryCurrentError.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/runtime/struct.TryCurrentError.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/runtime/struct.TryCurrentError.html">../../../tokio/runtime/struct.TryCurrentError.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/runtime/struct.TryCurrentError.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
242
tokio/runtime/index.html
Normal file
242
tokio/runtime/index.html
Normal file
|
|
@ -0,0 +1,242 @@
|
|||
<!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="The Tokio runtime."><title>tokio::runtime - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.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" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.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.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.42.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module runtime</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#usage" title="Usage">Usage</a><ul><li><a href="#runtime-configurations" title="Runtime Configurations">Runtime Configurations</a></li><li><a href="#lifetime-of-spawned-threads" title="Lifetime of spawned threads">Lifetime of spawned threads</a></li></ul></li><li><a href="#detailed-runtime-behavior" title="Detailed runtime behavior">Detailed runtime behavior</a><ul><li><a href="#io-and-timers" title="IO and timers">IO and timers</a></li><li><a href="#current-thread-runtime-behavior-at-the-time-of-writing" title="Current thread runtime (behavior at the time of writing)">Current thread runtime (behavior at the time of writing)</a></li><li><a href="#multi-threaded-runtime-behavior-at-the-time-of-writing" title="Multi threaded runtime (behavior at the time of writing)">Multi threaded runtime (behavior at the time of writing)</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="#enums" title="Enums">Enums</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"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a></span><h1>Module <span>runtime</span><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/mod.rs.html#1-425">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The Tokio runtime.</p>
|
||||
<p>Unlike other Rust programs, asynchronous applications require runtime
|
||||
support. In particular, the following runtime services are necessary:</p>
|
||||
<ul>
|
||||
<li>An <strong>I/O event loop</strong>, called the driver, which drives I/O resources and
|
||||
dispatches I/O events to tasks that depend on them.</li>
|
||||
<li>A <strong>scheduler</strong> to execute <a href="../task/index.html" title="mod tokio::task">tasks</a> that use these I/O resources.</li>
|
||||
<li>A <strong>timer</strong> for scheduling work to run after a set period of time.</li>
|
||||
</ul>
|
||||
<p>Tokio’s <a href="struct.Runtime.html" title="struct tokio::runtime::Runtime"><code>Runtime</code></a> bundles all of these services as a single type, allowing
|
||||
them to be started, shut down, and configured together. However, often it is
|
||||
not required to configure a <a href="struct.Runtime.html" title="struct tokio::runtime::Runtime"><code>Runtime</code></a> manually, and a user may just use the
|
||||
<a href="../attr.main.html"><code>tokio::main</code></a> attribute macro, which creates a <a href="struct.Runtime.html" title="struct tokio::runtime::Runtime"><code>Runtime</code></a> under the hood.</p>
|
||||
<h2 id="usage"><a class="doc-anchor" href="#usage">§</a>Usage</h2>
|
||||
<p>When no fine tuning is required, the <a href="../attr.main.html"><code>tokio::main</code></a> attribute macro can be
|
||||
used.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpListener;
|
||||
<span class="kw">use </span>tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
|
||||
<span class="attr">#[tokio::main]
|
||||
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>std::error::Error>> {
|
||||
<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>(<span class="kw-2">mut </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="kw">let </span><span class="kw-2">mut </span>buf = [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="comment">// In a loop, read data from the socket and write the data back.
|
||||
</span><span class="kw">loop </span>{
|
||||
<span class="kw">let </span>n = <span class="kw">match </span>socket.read(<span class="kw-2">&mut </span>buf).<span class="kw">await </span>{
|
||||
<span class="comment">// socket closed
|
||||
</span><span class="prelude-val">Ok</span>(n) <span class="kw">if </span>n == <span class="number">0 </span>=> <span class="kw">return</span>,
|
||||
<span class="prelude-val">Ok</span>(n) => n,
|
||||
<span class="prelude-val">Err</span>(e) => {
|
||||
<span class="macro">println!</span>(<span class="string">"failed to read from socket; err = {:?}"</span>, e);
|
||||
<span class="kw">return</span>;
|
||||
}
|
||||
};
|
||||
|
||||
<span class="comment">// Write the data back
|
||||
</span><span class="kw">if let </span><span class="prelude-val">Err</span>(e) = socket.write_all(<span class="kw-2">&</span>buf[<span class="number">0</span>..n]).<span class="kw">await </span>{
|
||||
<span class="macro">println!</span>(<span class="string">"failed to write to socket; err = {:?}"</span>, e);
|
||||
<span class="kw">return</span>;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}</code></pre></div>
|
||||
<p>From within the context of the runtime, additional tasks are spawned using
|
||||
the <a href="../task/fn.spawn.html" title="fn tokio::task::spawn"><code>tokio::spawn</code></a> function. Futures spawned using this function will be
|
||||
executed on the same thread pool used by the <a href="struct.Runtime.html" title="struct tokio::runtime::Runtime"><code>Runtime</code></a>.</p>
|
||||
<p>A <a href="struct.Runtime.html" title="struct tokio::runtime::Runtime"><code>Runtime</code></a> instance can also be used directly.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpListener;
|
||||
<span class="kw">use </span>tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
<span class="kw">use </span>tokio::runtime::Runtime;
|
||||
|
||||
<span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>std::error::Error>> {
|
||||
<span class="comment">// Create the runtime
|
||||
</span><span class="kw">let </span>rt = Runtime::new()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Spawn the root task
|
||||
</span>rt.block_on(<span class="kw">async </span>{
|
||||
<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>(<span class="kw-2">mut </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="kw">let </span><span class="kw-2">mut </span>buf = [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="comment">// In a loop, read data from the socket and write the data back.
|
||||
</span><span class="kw">loop </span>{
|
||||
<span class="kw">let </span>n = <span class="kw">match </span>socket.read(<span class="kw-2">&mut </span>buf).<span class="kw">await </span>{
|
||||
<span class="comment">// socket closed
|
||||
</span><span class="prelude-val">Ok</span>(n) <span class="kw">if </span>n == <span class="number">0 </span>=> <span class="kw">return</span>,
|
||||
<span class="prelude-val">Ok</span>(n) => n,
|
||||
<span class="prelude-val">Err</span>(e) => {
|
||||
<span class="macro">println!</span>(<span class="string">"failed to read from socket; err = {:?}"</span>, e);
|
||||
<span class="kw">return</span>;
|
||||
}
|
||||
};
|
||||
|
||||
<span class="comment">// Write the data back
|
||||
</span><span class="kw">if let </span><span class="prelude-val">Err</span>(e) = socket.write_all(<span class="kw-2">&</span>buf[<span class="number">0</span>..n]).<span class="kw">await </span>{
|
||||
<span class="macro">println!</span>(<span class="string">"failed to write to socket; err = {:?}"</span>, e);
|
||||
<span class="kw">return</span>;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}</code></pre></div>
|
||||
<h3 id="runtime-configurations"><a class="doc-anchor" href="#runtime-configurations">§</a>Runtime Configurations</h3>
|
||||
<p>Tokio provides multiple task scheduling strategies, suitable for different
|
||||
applications. The <a href="struct.Builder.html" title="struct tokio::runtime::Builder">runtime builder</a> or <code>#[tokio::main]</code> attribute may be
|
||||
used to select which scheduler to use.</p>
|
||||
<h5 id="multi-thread-scheduler"><a class="doc-anchor" href="#multi-thread-scheduler">§</a>Multi-Thread Scheduler</h5>
|
||||
<p>The multi-thread scheduler executes futures on a <em>thread pool</em>, using a
|
||||
work-stealing strategy. By default, it will start a worker thread for each
|
||||
CPU core available on the system. This tends to be the ideal configuration
|
||||
for most applications. The multi-thread scheduler requires the <code>rt-multi-thread</code>
|
||||
feature flag, and is selected by default:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::runtime;
|
||||
|
||||
<span class="kw">let </span>threaded_rt = runtime::Runtime::new()<span class="question-mark">?</span>;</code></pre></div>
|
||||
<p>Most applications should use the multi-thread scheduler, except in some
|
||||
niche use-cases, such as when running only a single thread is required.</p>
|
||||
<h5 id="current-thread-scheduler"><a class="doc-anchor" href="#current-thread-scheduler">§</a>Current-Thread Scheduler</h5>
|
||||
<p>The current-thread scheduler provides a <em>single-threaded</em> future executor.
|
||||
All tasks will be created and executed on the current thread. This requires
|
||||
the <code>rt</code> feature flag.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::runtime;
|
||||
|
||||
<span class="kw">let </span>rt = runtime::Builder::new_current_thread()
|
||||
.build()<span class="question-mark">?</span>;</code></pre></div>
|
||||
<h5 id="resource-drivers"><a class="doc-anchor" href="#resource-drivers">§</a>Resource drivers</h5>
|
||||
<p>When configuring a runtime by hand, no resource drivers are enabled by
|
||||
default. In this case, attempting to use networking types or time types will
|
||||
fail. In order to enable these types, the resource drivers must be enabled.
|
||||
This is done with <a href="struct.Builder.html#method.enable_io" title="method tokio::runtime::Builder::enable_io"><code>Builder::enable_io</code></a> and <a href="struct.Builder.html#method.enable_time" title="method tokio::runtime::Builder::enable_time"><code>Builder::enable_time</code></a>. As a
|
||||
shorthand, <a href="struct.Builder.html#method.enable_all" title="method tokio::runtime::Builder::enable_all"><code>Builder::enable_all</code></a> enables both resource drivers.</p>
|
||||
<h3 id="lifetime-of-spawned-threads"><a class="doc-anchor" href="#lifetime-of-spawned-threads">§</a>Lifetime of spawned threads</h3>
|
||||
<p>The runtime may spawn threads depending on its configuration and usage. The
|
||||
multi-thread scheduler spawns threads to schedule tasks and for <code>spawn_blocking</code>
|
||||
calls.</p>
|
||||
<p>While the <code>Runtime</code> is active, threads may shut down after periods of being
|
||||
idle. Once <code>Runtime</code> is dropped, all runtime threads have usually been
|
||||
terminated, but in the presence of unstoppable spawned work are not
|
||||
guaranteed to have been terminated. See the
|
||||
<a href="struct.Runtime.html#shutdown" title="struct tokio::runtime::Runtime">struct level documentation</a> for more details.</p>
|
||||
<h2 id="detailed-runtime-behavior"><a class="doc-anchor" href="#detailed-runtime-behavior">§</a>Detailed runtime behavior</h2>
|
||||
<p>This section gives more details into how the Tokio runtime will schedule
|
||||
tasks for execution.</p>
|
||||
<p>At its most basic level, a runtime has a collection of tasks that need to be
|
||||
scheduled. It will repeatedly remove a task from that collection and
|
||||
schedule it (by calling <a href="https://doc.rust-lang.org/1.84.1/core/future/future/trait.Future.html#tymethod.poll" title="method core::future::future::Future::poll"><code>poll</code></a>). When the collection is empty, the thread
|
||||
will go to sleep until a task is added to the collection.</p>
|
||||
<p>However, the above is not sufficient to guarantee a well-behaved runtime.
|
||||
For example, the runtime might have a single task that is always ready to be
|
||||
scheduled, and schedule that task every time. This is a problem because it
|
||||
starves other tasks by not scheduling them. To solve this, Tokio provides
|
||||
the following fairness guarantee:</p>
|
||||
<blockquote>
|
||||
<p>If the total number of tasks does not grow without bound, and no task is
|
||||
<a href="https://ryhl.io/blog/async-what-is-blocking/">blocking the thread</a>, then it is guaranteed that tasks are scheduled
|
||||
fairly.</p>
|
||||
</blockquote>
|
||||
<p>Or, more formally:</p>
|
||||
<blockquote>
|
||||
<p>Under the following two assumptions:</p>
|
||||
<ul>
|
||||
<li>There is some number <code>MAX_TASKS</code> such that the total number of tasks on
|
||||
the runtime at any specific point in time never exceeds <code>MAX_TASKS</code>.</li>
|
||||
<li>There is some number <code>MAX_SCHEDULE</code> such that calling <a href="https://doc.rust-lang.org/1.84.1/core/future/future/trait.Future.html#tymethod.poll" title="method core::future::future::Future::poll"><code>poll</code></a> on any
|
||||
task spawned on the runtime returns within <code>MAX_SCHEDULE</code> time units.</li>
|
||||
</ul>
|
||||
<p>Then, there is some number <code>MAX_DELAY</code> such that when a task is woken, it
|
||||
will be scheduled by the runtime within <code>MAX_DELAY</code> time units.</p>
|
||||
</blockquote>
|
||||
<p>(Here, <code>MAX_TASKS</code> and <code>MAX_SCHEDULE</code> can be any number and the user of
|
||||
the runtime may choose them. The <code>MAX_DELAY</code> number is controlled by the
|
||||
runtime, and depends on the value of <code>MAX_TASKS</code> and <code>MAX_SCHEDULE</code>.)</p>
|
||||
<p>Other than the above fairness guarantee, there is no guarantee about the
|
||||
order in which tasks are scheduled. There is also no guarantee that the
|
||||
runtime is equally fair to all tasks. For example, if the runtime has two
|
||||
tasks A and B that are both ready, then the runtime may schedule A five
|
||||
times before it schedules B. This is the case even if A yields using
|
||||
<a href="../task/fn.yield_now.html" title="fn tokio::task::yield_now"><code>yield_now</code></a>. All that is guaranteed is that it will schedule B eventually.</p>
|
||||
<p>Normally, tasks are scheduled only if they have been woken by calling
|
||||
<a href="https://doc.rust-lang.org/1.84.1/core/task/wake/struct.Waker.html#method.wake" title="method core::task::wake::Waker::wake"><code>wake</code></a> on their waker. However, this is not guaranteed, and Tokio may
|
||||
schedule tasks that have not been woken under some circumstances. This is
|
||||
called a spurious wakeup.</p>
|
||||
<h3 id="io-and-timers"><a class="doc-anchor" href="#io-and-timers">§</a>IO and timers</h3>
|
||||
<p>Beyond just scheduling tasks, the runtime must also manage IO resources and
|
||||
timers. It does this by periodically checking whether there are any IO
|
||||
resources or timers that are ready, and waking the relevant task so that
|
||||
it will be scheduled.</p>
|
||||
<p>These checks are performed periodically between scheduling tasks. Under the
|
||||
same assumptions as the previous fairness guarantee, Tokio guarantees that
|
||||
it will wake tasks with an IO or timer event within some maximum number of
|
||||
time units.</p>
|
||||
<h3 id="current-thread-runtime-behavior-at-the-time-of-writing"><a class="doc-anchor" href="#current-thread-runtime-behavior-at-the-time-of-writing">§</a>Current thread runtime (behavior at the time of writing)</h3>
|
||||
<p>This section describes how the <a href="struct.Builder.html#method.new_current_thread" title="associated function tokio::runtime::Builder::new_current_thread">current thread runtime</a> behaves today. This
|
||||
behavior may change in future versions of Tokio.</p>
|
||||
<p>The current thread runtime maintains two FIFO queues of tasks that are ready
|
||||
to be scheduled: the global queue and the local queue. The runtime will prefer
|
||||
to choose the next task to schedule from the local queue, and will only pick a
|
||||
task from the global queue if the local queue is empty, or if it has picked
|
||||
a task from the local queue 31 times in a row. The number 31 can be
|
||||
changed using the <a href="struct.Builder.html#method.global_queue_interval" title="method tokio::runtime::Builder::global_queue_interval"><code>global_queue_interval</code></a> setting.</p>
|
||||
<p>The runtime will check for new IO or timer events whenever there are no
|
||||
tasks ready to be scheduled, or when it has scheduled 61 tasks in a row. The
|
||||
number 61 may be changed using the <a href="struct.Builder.html#method.event_interval" title="method tokio::runtime::Builder::event_interval"><code>event_interval</code></a> setting.</p>
|
||||
<p>When a task is woken from within a task running on the runtime, then the
|
||||
woken task is added directly to the local queue. Otherwise, the task is
|
||||
added to the global queue. The current thread runtime does not use <a href="struct.Builder.html#structfield.disable_lifo_slot" title="field tokio::runtime::Builder::disable_lifo_slot">the lifo
|
||||
slot optimization</a>.</p>
|
||||
<h3 id="multi-threaded-runtime-behavior-at-the-time-of-writing"><a class="doc-anchor" href="#multi-threaded-runtime-behavior-at-the-time-of-writing">§</a>Multi threaded runtime (behavior at the time of writing)</h3>
|
||||
<p>This section describes how the <a href="struct.Builder.html#method.new_multi_thread" title="associated function tokio::runtime::Builder::new_multi_thread">multi thread runtime</a> behaves today. This
|
||||
behavior may change in future versions of Tokio.</p>
|
||||
<p>A multi thread runtime has a fixed number of worker threads, which are all
|
||||
created on startup. The multi thread runtime maintains one global queue, and
|
||||
a local queue for each worker thread. The local queue of a worker thread can
|
||||
fit at most 256 tasks. If more than 256 tasks are added to the local queue,
|
||||
then half of them are moved to the global queue to make space.</p>
|
||||
<p>The runtime will prefer to choose the next task to schedule from the local
|
||||
queue, and will only pick a task from the global queue if the local queue is
|
||||
empty, or if it has picked a task from the local queue
|
||||
<a href="struct.Builder.html#method.global_queue_interval" title="method tokio::runtime::Builder::global_queue_interval"><code>global_queue_interval</code></a> times in a row. If the value of
|
||||
<a href="struct.Builder.html#method.global_queue_interval" title="method tokio::runtime::Builder::global_queue_interval"><code>global_queue_interval</code></a> is not explicitly set using the runtime builder,
|
||||
then the runtime will dynamically compute it using a heuristic that targets
|
||||
10ms intervals between each check of the global queue (based on the
|
||||
<a href="crate::runtime::RuntimeMetrics::worker_mean_poll_time"><code>worker_mean_poll_time</code></a> metric).</p>
|
||||
<p>If both the local queue and global queue is empty, then the worker thread
|
||||
will attempt to steal tasks from the local queue of another worker thread.
|
||||
Stealing is done by moving half of the tasks in one local queue to another
|
||||
local queue.</p>
|
||||
<p>The runtime will check for new IO or timer events whenever there are no
|
||||
tasks ready to be scheduled, or when it has scheduled 61 tasks in a row. The
|
||||
number 61 may be changed using the <a href="struct.Builder.html#method.event_interval" title="method tokio::runtime::Builder::event_interval"><code>event_interval</code></a> setting.</p>
|
||||
<p>The multi thread runtime uses <a href="struct.Builder.html#structfield.disable_lifo_slot" title="field tokio::runtime::Builder::disable_lifo_slot">the lifo slot optimization</a>: Whenever a task
|
||||
wakes up another task, the other task is added to the worker thread’s lifo
|
||||
slot instead of being added to a queue. If there was already a task in the
|
||||
lifo slot when this happened, then the lifo slot is replaced, and the task
|
||||
that used to be in the lifo slot is placed in the thread’s local queue.
|
||||
When the runtime finishes scheduling a task, it will schedule the task in
|
||||
the lifo slot immediately, if any. When the lifo slot is used, the <a href="../task/index.html#cooperative-scheduling" title="mod tokio::task">coop
|
||||
budget</a> is not reset. Furthermore, if a worker thread uses the lifo slot
|
||||
three times in a row, it is temporarily disabled until the worker thread has
|
||||
scheduled a task that didn’t come from the lifo slot. The lifo slot can be
|
||||
disabled using the <a href="struct.Builder.html#structfield.disable_lifo_slot" title="field tokio::runtime::Builder::disable_lifo_slot"><code>disable_lifo_slot</code></a> setting. The lifo slot is separate
|
||||
from the local queue, so other worker threads cannot steal the task in the
|
||||
lifo slot.</p>
|
||||
<p>When a task is woken from a thread that is not a worker thread, then the
|
||||
task is placed in the global queue.</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></div><div class="desc docblock-short">Builds Tokio Runtime with custom configuration values.</div></li><li><div class="item-name"><a class="struct" href="struct.EnterGuard.html" title="struct tokio::runtime::EnterGuard">Enter<wbr>Guard</a></div><div class="desc docblock-short">Runtime context guard.</div></li><li><div class="item-name"><a class="struct" href="struct.Handle.html" title="struct tokio::runtime::Handle">Handle</a></div><div class="desc docblock-short">Handle to the runtime.</div></li><li><div class="item-name"><a class="struct" href="struct.Runtime.html" title="struct tokio::runtime::Runtime">Runtime</a></div><div class="desc docblock-short">The Tokio runtime.</div></li><li><div class="item-name"><a class="struct" href="struct.RuntimeMetrics.html" title="struct tokio::runtime::RuntimeMetrics">Runtime<wbr>Metrics</a></div><div class="desc docblock-short">Handle to the runtime’s metrics.</div></li><li><div class="item-name"><a class="struct" href="struct.TryCurrentError.html" title="struct tokio::runtime::TryCurrentError">TryCurrent<wbr>Error</a></div><div class="desc docblock-short">Error returned by <code>try_current</code> when no Runtime has been started</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.RuntimeFlavor.html" title="enum tokio::runtime::RuntimeFlavor">Runtime<wbr>Flavor</a></div><div class="desc docblock-short">The flavor of a <code>Runtime</code>.</div></li></ul></section></div></main></body></html>
|
||||
11
tokio/runtime/metrics/runtime/struct.RuntimeMetrics.html
Normal file
11
tokio/runtime/metrics/runtime/struct.RuntimeMetrics.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/runtime/struct.RuntimeMetrics.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/runtime/struct.RuntimeMetrics.html">../../../../tokio/runtime/struct.RuntimeMetrics.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/runtime/struct.RuntimeMetrics.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tokio/runtime/runtime/enum.RuntimeFlavor.html
Normal file
11
tokio/runtime/runtime/enum.RuntimeFlavor.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/runtime/enum.RuntimeFlavor.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/runtime/enum.RuntimeFlavor.html">../../../tokio/runtime/enum.RuntimeFlavor.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/runtime/enum.RuntimeFlavor.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tokio/runtime/runtime/struct.Runtime.html
Normal file
11
tokio/runtime/runtime/struct.Runtime.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/runtime/struct.Runtime.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/runtime/struct.Runtime.html">../../../tokio/runtime/struct.Runtime.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/runtime/struct.Runtime.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
1
tokio/runtime/sidebar-items.js
Normal file
1
tokio/runtime/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"enum":["RuntimeFlavor"],"struct":["Builder","EnterGuard","Handle","Runtime","RuntimeMetrics","TryCurrentError"]};
|
||||
292
tokio/runtime/struct.Builder.html
Normal file
292
tokio/runtime/struct.Builder.html
Normal file
File diff suppressed because one or more lines are too long
14
tokio/runtime/struct.EnterGuard.html
Normal file
14
tokio/runtime/struct.EnterGuard.html
Normal file
File diff suppressed because one or more lines are too long
180
tokio/runtime/struct.Handle.html
Normal file
180
tokio/runtime/struct.Handle.html
Normal file
File diff suppressed because one or more lines are too long
232
tokio/runtime/struct.Runtime.html
Normal file
232
tokio/runtime/struct.Runtime.html
Normal file
File diff suppressed because one or more lines are too long
60
tokio/runtime/struct.RuntimeMetrics.html
Normal file
60
tokio/runtime/struct.RuntimeMetrics.html
Normal file
File diff suppressed because one or more lines are too long
18
tokio/runtime/struct.TryCurrentError.html
Normal file
18
tokio/runtime/struct.TryCurrentError.html
Normal file
File diff suppressed because one or more lines are too long
11
tokio/runtime/task/abort/struct.AbortHandle.html
Normal file
11
tokio/runtime/task/abort/struct.AbortHandle.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/task/struct.AbortHandle.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/task/struct.AbortHandle.html">../../../../tokio/task/struct.AbortHandle.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/task/struct.AbortHandle.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tokio/runtime/task/error/struct.JoinError.html
Normal file
11
tokio/runtime/task/error/struct.JoinError.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/task/struct.JoinError.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/task/struct.JoinError.html">../../../../tokio/task/struct.JoinError.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/task/struct.JoinError.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tokio/runtime/task/id/fn.id.html
Normal file
11
tokio/runtime/task/id/fn.id.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/task/fn.id.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/task/fn.id.html">../../../../tokio/task/fn.id.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/task/fn.id.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tokio/runtime/task/id/fn.try_id.html
Normal file
11
tokio/runtime/task/id/fn.try_id.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/task/fn.try_id.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/task/fn.try_id.html">../../../../tokio/task/fn.try_id.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/task/fn.try_id.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tokio/runtime/task/id/struct.Id.html
Normal file
11
tokio/runtime/task/id/struct.Id.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/task/struct.Id.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/task/struct.Id.html">../../../../tokio/task/struct.Id.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/task/struct.Id.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tokio/runtime/task/join/struct.JoinHandle.html
Normal file
11
tokio/runtime/task/join/struct.JoinHandle.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/task/struct.JoinHandle.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/task/struct.JoinHandle.html">../../../../tokio/task/struct.JoinHandle.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/task/struct.JoinHandle.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue