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
24
tokio/sync/broadcast/error/enum.RecvError.html
Normal file
24
tokio/sync/broadcast/error/enum.RecvError.html
Normal file
File diff suppressed because one or more lines are too long
28
tokio/sync/broadcast/error/enum.TryRecvError.html
Normal file
28
tokio/sync/broadcast/error/enum.TryRecvError.html
Normal file
File diff suppressed because one or more lines are too long
2
tokio/sync/broadcast/error/index.html
Normal file
2
tokio/sync/broadcast/error/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!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="Broadcast error types"><title>tokio::sync::broadcast::error - 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 error</a></h2><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><a href="../index.html">In tokio::<wbr>sync::<wbr>broadcast</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">sync</a>::<wbr><a href="../index.html">broadcast</a></span><h1>Module <span>error</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/sync/broadcast.rs.html#213">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Broadcast error types</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.SendError.html" title="struct tokio::sync::broadcast::error::SendError">Send<wbr>Error</a></div><div class="desc docblock-short">Error returned by the <a href="../struct.Sender.html#method.send" title="method tokio::sync::broadcast::Sender::send"><code>send</code></a> function on a <a href="../struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a>.</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.RecvError.html" title="enum tokio::sync::broadcast::error::RecvError">Recv<wbr>Error</a></div><div class="desc docblock-short">An error returned from the <a href="../struct.Receiver.html#method.recv" title="method tokio::sync::broadcast::Receiver::recv"><code>recv</code></a> function on a <a href="../struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a>.</div></li><li><div class="item-name"><a class="enum" href="enum.TryRecvError.html" title="enum tokio::sync::broadcast::error::TryRecvError">TryRecv<wbr>Error</a></div><div class="desc docblock-short">An error returned from the <a href="../struct.Receiver.html#method.try_recv" title="method tokio::sync::broadcast::Receiver::try_recv"><code>try_recv</code></a> function on a <a href="../struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a>.</div></li></ul></section></div></main></body></html>
|
||||
1
tokio/sync/broadcast/error/sidebar-items.js
Normal file
1
tokio/sync/broadcast/error/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"enum":["RecvError","TryRecvError"],"struct":["SendError"]};
|
||||
22
tokio/sync/broadcast/error/struct.SendError.html
Normal file
22
tokio/sync/broadcast/error/struct.SendError.html
Normal file
File diff suppressed because one or more lines are too long
36
tokio/sync/broadcast/fn.channel.html
Normal file
36
tokio/sync/broadcast/fn.channel.html
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<!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="Create a bounded, multi-producer, multi-consumer channel where each sent value is broadcasted to all active receivers."><title>channel in tokio::sync::broadcast - 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 fn"><!--[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="#">channel</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>sync::<wbr>broadcast</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">sync</a>::<wbr><a href="index.html">broadcast</a></span><h1>Function <span class="fn">channel</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/sync/broadcast.rs.html#460-468">Source</a> </span></div><pre class="rust item-decl"><code>pub fn channel<T: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>>(capacity: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.usize.html">usize</a>) -> (<a class="struct" href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender">Sender</a><T>, <a class="struct" href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver">Receiver</a><T>)</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Create a bounded, multi-producer, multi-consumer channel where each sent
|
||||
value is broadcasted to all active receivers.</p>
|
||||
<p><strong>Note:</strong> The actual capacity may be greater than the provided <code>capacity</code>.</p>
|
||||
<p>All data sent on <a href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a> will become available on every active
|
||||
<a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> in the same order as it was sent.</p>
|
||||
<p>The <code>Sender</code> can be cloned to <code>send</code> to the same channel from multiple
|
||||
points in the process or it can be used concurrently from an <code>Arc</code>. New
|
||||
<code>Receiver</code> handles are created by calling <a href="struct.Sender.html#method.subscribe" title="method tokio::sync::broadcast::Sender::subscribe"><code>Sender::subscribe</code></a>.</p>
|
||||
<p>If all <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> handles are dropped, the <code>send</code> method will return a
|
||||
<a href="error/struct.SendError.html" title="struct tokio::sync::broadcast::error::SendError"><code>SendError</code></a>. Similarly, if all <a href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a> handles are dropped, the <a href="struct.Receiver.html#method.recv" title="method tokio::sync::broadcast::Receiver::recv"><code>recv</code></a>
|
||||
method will return a <a href="error/enum.RecvError.html" title="enum tokio::sync::broadcast::error::RecvError"><code>RecvError</code></a>.</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::sync::broadcast;
|
||||
|
||||
<span class="attr">#[tokio::main]
|
||||
</span><span class="kw">async fn </span>main() {
|
||||
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx1) = broadcast::channel(<span class="number">16</span>);
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>rx2 = tx.subscribe();
|
||||
|
||||
tokio::spawn(<span class="kw">async move </span>{
|
||||
<span class="macro">assert_eq!</span>(rx1.recv().<span class="kw">await</span>.unwrap(), <span class="number">10</span>);
|
||||
<span class="macro">assert_eq!</span>(rx1.recv().<span class="kw">await</span>.unwrap(), <span class="number">20</span>);
|
||||
});
|
||||
|
||||
tokio::spawn(<span class="kw">async move </span>{
|
||||
<span class="macro">assert_eq!</span>(rx2.recv().<span class="kw">await</span>.unwrap(), <span class="number">10</span>);
|
||||
<span class="macro">assert_eq!</span>(rx2.recv().<span class="kw">await</span>.unwrap(), <span class="number">20</span>);
|
||||
});
|
||||
|
||||
tx.send(<span class="number">10</span>).unwrap();
|
||||
tx.send(<span class="number">20</span>).unwrap();
|
||||
}</code></pre></div>
|
||||
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
|
||||
<p>This will panic if <code>capacity</code> is equal to <code>0</code> or larger
|
||||
than <code>usize::MAX / 2</code>.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
90
tokio/sync/broadcast/index.html
Normal file
90
tokio/sync/broadcast/index.html
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<!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="A multi-producer, multi-consumer broadcast queue. Each sent value is seen by all consumers."><title>tokio::sync::broadcast - 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 broadcast</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#lagging" title="Lagging">Lagging</a></li><li><a href="#closing" title="Closing">Closing</a></li><li><a href="#examples" title="Examples">Examples</a></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><a href="../index.html">In tokio::<wbr>sync</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">sync</a></span><h1>Module <span>broadcast</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/sync/broadcast.rs.html#1-1541">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A multi-producer, multi-consumer broadcast queue. Each sent value is seen by
|
||||
all consumers.</p>
|
||||
<p>A <a href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a> is used to broadcast values to <strong>all</strong> connected <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a>
|
||||
values. <a href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a> handles are clone-able, allowing concurrent send and
|
||||
receive actions. <a href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a> and <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> are both <code>Send</code> and <code>Sync</code> as
|
||||
long as <code>T</code> is <code>Send</code>.</p>
|
||||
<p>When a value is sent, <strong>all</strong> <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> handles are notified and will
|
||||
receive the value. The value is stored once inside the channel and cloned on
|
||||
demand for each receiver. Once all receivers have received a clone of the
|
||||
value, the value is released from the channel.</p>
|
||||
<p>A channel is created by calling <a href="fn.channel.html" title="fn tokio::sync::broadcast::channel"><code>channel</code></a>, specifying the maximum number
|
||||
of messages the channel can retain at any given time.</p>
|
||||
<p>New <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> handles are created by calling <a href="struct.Sender.html#method.subscribe" title="method tokio::sync::broadcast::Sender::subscribe"><code>Sender::subscribe</code></a>. The
|
||||
returned <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> will receive values sent <strong>after</strong> the call to
|
||||
<code>subscribe</code>.</p>
|
||||
<p>This channel is also suitable for the single-producer multi-consumer
|
||||
use-case, where a single sender broadcasts values to many receivers.</p>
|
||||
<h3 id="lagging"><a class="doc-anchor" href="#lagging">§</a>Lagging</h3>
|
||||
<p>As sent messages must be retained until <strong>all</strong> <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> handles receive
|
||||
a clone, broadcast channels are susceptible to the “slow receiver” problem.
|
||||
In this case, all but one receiver are able to receive values at the rate
|
||||
they are sent. Because one receiver is stalled, the channel starts to fill
|
||||
up.</p>
|
||||
<p>This broadcast channel implementation handles this case by setting a hard
|
||||
upper bound on the number of values the channel may retain at any given
|
||||
time. This upper bound is passed to the <a href="fn.channel.html" title="fn tokio::sync::broadcast::channel"><code>channel</code></a> function as an argument.</p>
|
||||
<p>If a value is sent when the channel is at capacity, the oldest value
|
||||
currently held by the channel is released. This frees up space for the new
|
||||
value. Any receiver that has not yet seen the released value will return
|
||||
<a href="error/enum.RecvError.html#variant.Lagged" title="variant tokio::sync::broadcast::error::RecvError::Lagged"><code>RecvError::Lagged</code></a> the next time <a href="struct.Receiver.html#method.recv" title="method tokio::sync::broadcast::Receiver::recv"><code>recv</code></a> is called.</p>
|
||||
<p>Once <a href="error/enum.RecvError.html#variant.Lagged" title="variant tokio::sync::broadcast::error::RecvError::Lagged"><code>RecvError::Lagged</code></a> is returned, the lagging receiver’s position is
|
||||
updated to the oldest value contained by the channel. The next call to
|
||||
<a href="struct.Receiver.html#method.recv" title="method tokio::sync::broadcast::Receiver::recv"><code>recv</code></a> will return this value.</p>
|
||||
<p>This behavior enables a receiver to detect when it has lagged so far behind
|
||||
that data has been dropped. The caller may decide how to respond to this:
|
||||
either by aborting its task or by tolerating lost messages and resuming
|
||||
consumption of the channel.</p>
|
||||
<h3 id="closing"><a class="doc-anchor" href="#closing">§</a>Closing</h3>
|
||||
<p>When <strong>all</strong> <a href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a> handles have been dropped, no new values may be
|
||||
sent. At this point, the channel is “closed”. Once a receiver has received
|
||||
all values retained by the channel, the next call to <a href="struct.Receiver.html#method.recv" title="method tokio::sync::broadcast::Receiver::recv"><code>recv</code></a> will return
|
||||
with <a href="error/enum.RecvError.html#variant.Closed" title="variant tokio::sync::broadcast::error::RecvError::Closed"><code>RecvError::Closed</code></a>.</p>
|
||||
<p>When a <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> handle is dropped, any messages not read by the receiver
|
||||
will be marked as read. If this receiver was the only one not to have read
|
||||
that message, the message will be dropped at this point.</p>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<p>Basic usage</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::broadcast;
|
||||
|
||||
<span class="attr">#[tokio::main]
|
||||
</span><span class="kw">async fn </span>main() {
|
||||
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx1) = broadcast::channel(<span class="number">16</span>);
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>rx2 = tx.subscribe();
|
||||
|
||||
tokio::spawn(<span class="kw">async move </span>{
|
||||
<span class="macro">assert_eq!</span>(rx1.recv().<span class="kw">await</span>.unwrap(), <span class="number">10</span>);
|
||||
<span class="macro">assert_eq!</span>(rx1.recv().<span class="kw">await</span>.unwrap(), <span class="number">20</span>);
|
||||
});
|
||||
|
||||
tokio::spawn(<span class="kw">async move </span>{
|
||||
<span class="macro">assert_eq!</span>(rx2.recv().<span class="kw">await</span>.unwrap(), <span class="number">10</span>);
|
||||
<span class="macro">assert_eq!</span>(rx2.recv().<span class="kw">await</span>.unwrap(), <span class="number">20</span>);
|
||||
});
|
||||
|
||||
tx.send(<span class="number">10</span>).unwrap();
|
||||
tx.send(<span class="number">20</span>).unwrap();
|
||||
}</code></pre></div>
|
||||
<p>Handling lag</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::broadcast;
|
||||
|
||||
<span class="attr">#[tokio::main]
|
||||
</span><span class="kw">async fn </span>main() {
|
||||
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx) = broadcast::channel(<span class="number">2</span>);
|
||||
|
||||
tx.send(<span class="number">10</span>).unwrap();
|
||||
tx.send(<span class="number">20</span>).unwrap();
|
||||
tx.send(<span class="number">30</span>).unwrap();
|
||||
|
||||
<span class="comment">// The receiver lagged behind
|
||||
</span><span class="macro">assert!</span>(rx.recv().<span class="kw">await</span>.is_err());
|
||||
|
||||
<span class="comment">// At this point, we can abort or continue with lost messages
|
||||
|
||||
</span><span class="macro">assert_eq!</span>(<span class="number">20</span>, rx.recv().<span class="kw">await</span>.unwrap());
|
||||
<span class="macro">assert_eq!</span>(<span class="number">30</span>, rx.recv().<span class="kw">await</span>.unwrap());
|
||||
}</code></pre></div>
|
||||
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="error/index.html" title="mod tokio::sync::broadcast::error">error</a></div><div class="desc docblock-short">Broadcast error types</div></li></ul><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.Receiver.html" title="struct tokio::sync::broadcast::Receiver">Receiver</a></div><div class="desc docblock-short">Receiving-half of the <a href="index.html" title="mod tokio::sync::broadcast"><code>broadcast</code></a> channel.</div></li><li><div class="item-name"><a class="struct" href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender">Sender</a></div><div class="desc docblock-short">Sending-half of the <a href="index.html" title="mod tokio::sync::broadcast"><code>broadcast</code></a> channel.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.channel.html" title="fn tokio::sync::broadcast::channel">channel</a></div><div class="desc docblock-short">Create a bounded, multi-producer, multi-consumer channel where each sent
|
||||
value is broadcasted to all active receivers.</div></li></ul></section></div></main></body></html>
|
||||
1
tokio/sync/broadcast/sidebar-items.js
Normal file
1
tokio/sync/broadcast/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"fn":["channel"],"mod":["error"],"struct":["Receiver","Sender"]};
|
||||
217
tokio/sync/broadcast/struct.Receiver.html
Normal file
217
tokio/sync/broadcast/struct.Receiver.html
Normal file
File diff suppressed because one or more lines are too long
188
tokio/sync/broadcast/struct.Sender.html
Normal file
188
tokio/sync/broadcast/struct.Sender.html
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue