203 lines
41 KiB
HTML
203 lines
41 KiB
HTML
<!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 Condition Variable"><title>Condvar in parking_lot - 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="parking_lot" 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 struct"><!--[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="#">Condvar</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../parking_lot/index.html">parking_<wbr>lot</a><span class="version">0.12.5</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Condvar</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#differences-from-the-standard-library-condvar" title="Differences from the standard library `Condvar`">Differences from the standard library <code>Condvar</code></a></li><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.new" title="new">new</a></li><li><a href="#method.notify_all" title="notify_all">notify_all</a></li><li><a href="#method.notify_one" title="notify_one">notify_one</a></li><li><a href="#method.wait" title="wait">wait</a></li><li><a href="#method.wait_for" title="wait_for">wait_for</a></li><li><a href="#method.wait_until" title="wait_until">wait_until</a></li><li><a href="#method.wait_while" title="wait_while">wait_while</a></li><li><a href="#method.wait_while_for" title="wait_while_for">wait_while_for</a></li><li><a href="#method.wait_while_until" title="wait_while_until">wait_while_until</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Debug-for-Condvar" title="Debug">Debug</a></li><li><a href="#impl-Default-for-Condvar" title="Default">Default</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-Condvar" title="!Freeze">!Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Condvar" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Condvar" title="Send">Send</a></li><li><a href="#impl-Sync-for-Condvar" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-Condvar" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Condvar" 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 class="in-crate"><a href="index.html">In crate parking_<wbr>lot</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">parking_lot</a></div><h1>Struct <span class="struct">Condvar</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/parking_lot/condvar.rs.html#90-92">Source</a> </span></div><pre class="rust item-decl"><code>pub struct Condvar { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A Condition Variable</p>
|
|
<p>Condition variables represent the ability to block a thread such that it
|
|
consumes no CPU time while waiting for an event to occur. Condition
|
|
variables are typically associated with a boolean predicate (a condition)
|
|
and a mutex. The predicate is always verified inside of the mutex before
|
|
determining that thread must block.</p>
|
|
<p>Note that this module places one additional restriction over the system
|
|
condition variables: each condvar can be used with only one mutex at a
|
|
time. Any attempt to use multiple mutexes on the same condition variable
|
|
simultaneously will result in a runtime panic. However it is possible to
|
|
switch to a different mutex if there are no threads currently waiting on
|
|
the condition variable.</p>
|
|
<h2 id="differences-from-the-standard-library-condvar"><a class="doc-anchor" href="#differences-from-the-standard-library-condvar">§</a>Differences from the standard library <code>Condvar</code></h2>
|
|
<ul>
|
|
<li>No spurious wakeups: A wait will only return a non-timeout result if it
|
|
was woken up by <code>notify_one</code> or <code>notify_all</code>.</li>
|
|
<li><code>Condvar::notify_all</code> will only wake up a single thread, the rest are
|
|
requeued to wait for the <code>Mutex</code> to be unlocked by the thread that was
|
|
woken up.</li>
|
|
<li>Only requires 1 word of space, whereas the standard library boxes the
|
|
<code>Condvar</code> due to platform limitations.</li>
|
|
<li>Can be statically constructed.</li>
|
|
<li>Does not require any drop glue when dropped.</li>
|
|
<li>Inline fast path for the uncontended case.</li>
|
|
</ul>
|
|
<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>parking_lot::{Mutex, Condvar};
|
|
<span class="kw">use </span>std::sync::Arc;
|
|
<span class="kw">use </span>std::thread;
|
|
|
|
<span class="kw">let </span>pair = Arc::new((Mutex::new(<span class="bool-val">false</span>), Condvar::new()));
|
|
<span class="kw">let </span>pair2 = pair.clone();
|
|
|
|
<span class="comment">// Inside of our lock, spawn a new thread, and then wait for it to start
|
|
</span>thread::spawn(<span class="kw">move</span>|| {
|
|
<span class="kw">let </span><span class="kw-2">&</span>(<span class="kw-2">ref </span>lock, <span class="kw-2">ref </span>cvar) = <span class="kw-2">&*</span>pair2;
|
|
<span class="kw">let </span><span class="kw-2">mut </span>started = lock.lock();
|
|
<span class="kw-2">*</span>started = <span class="bool-val">true</span>;
|
|
cvar.notify_one();
|
|
});
|
|
|
|
<span class="comment">// wait for the thread to start up
|
|
</span><span class="kw">let </span><span class="kw-2">&</span>(<span class="kw-2">ref </span>lock, <span class="kw-2">ref </span>cvar) = <span class="kw-2">&*</span>pair;
|
|
<span class="kw">let </span><span class="kw-2">mut </span>started = lock.lock();
|
|
<span class="kw">if </span>!<span class="kw-2">*</span>started {
|
|
cvar.wait(<span class="kw-2">&mut </span>started);
|
|
}
|
|
<span class="comment">// Note that we used an if instead of a while loop above. This is only
|
|
// possible because parking_lot's Condvar will never spuriously wake up.
|
|
// This means that wait() will only return after notify_one or notify_all is
|
|
// called.</span></code></pre></div></div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Condvar" class="impl"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#94-510">Source</a><a href="#impl-Condvar" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Condvar.html" title="struct parking_lot::Condvar">Condvar</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#98-102">Source</a><h4 class="code-header">pub const fn <a href="#method.new" class="fn">new</a>() -> <a class="struct" href="struct.Condvar.html" title="struct parking_lot::Condvar">Condvar</a></h4></section></summary><div class="docblock"><p>Creates a new condition variable which is ready to be waited on and
|
|
notified.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.notify_one" class="method"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#128-136">Source</a><h4 class="code-header">pub fn <a href="#method.notify_one" class="fn">notify_one</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Wakes up one blocked thread on this condvar.</p>
|
|
<p>Returns whether a thread was woken up.</p>
|
|
<p>If there is a blocked thread on this condition variable, then it will
|
|
be woken up from its call to <code>wait</code> or <code>wait_timeout</code>. Calls to
|
|
<code>notify_one</code> are not buffered in any way.</p>
|
|
<p>To wake up all threads, see <code>notify_all()</code>.</p>
|
|
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>parking_lot::Condvar;
|
|
|
|
<span class="kw">let </span>condvar = Condvar::new();
|
|
|
|
<span class="comment">// do something with condvar, share it with other threads
|
|
|
|
</span><span class="kw">if </span>!condvar.notify_one() {
|
|
<span class="macro">println!</span>(<span class="string">"Nobody was listening for this."</span>);
|
|
}</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.notify_all" class="method"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#187-195">Source</a><h4 class="code-header">pub fn <a href="#method.notify_all" class="fn">notify_all</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Wakes up all blocked threads on this condvar.</p>
|
|
<p>Returns the number of threads woken up.</p>
|
|
<p>This method will ensure that any current waiters on the condition
|
|
variable are awoken. Calls to <code>notify_all()</code> are not buffered in any
|
|
way.</p>
|
|
<p>To wake up only one thread, see <code>notify_one()</code>.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.wait" class="method"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#255-257">Source</a><h4 class="code-header">pub fn <a href="#method.wait" class="fn">wait</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&self, mutex_guard: &mut <a class="type" href="type.MutexGuard.html" title="type parking_lot::MutexGuard">MutexGuard</a><'_, T>)</h4></section></summary><div class="docblock"><p>Blocks the current thread until this condition variable receives a
|
|
notification.</p>
|
|
<p>This function will atomically unlock the mutex specified (represented by
|
|
<code>mutex_guard</code>) and block the current thread. This means that any calls
|
|
to <code>notify_*()</code> which happen logically after the mutex is unlocked are
|
|
candidates to wake this thread up. When this function call returns, the
|
|
lock specified will have been re-acquired.</p>
|
|
<h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
|
|
<p>This function will panic if another thread is waiting on the <code>Condvar</code>
|
|
with a different <code>Mutex</code> object.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.wait_until" class="method"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#283-292">Source</a><h4 class="code-header">pub fn <a href="#method.wait_until" class="fn">wait_until</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(
|
|
&self,
|
|
mutex_guard: &mut <a class="type" href="type.MutexGuard.html" title="type parking_lot::MutexGuard">MutexGuard</a><'_, T>,
|
|
timeout: <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/time/struct.Instant.html" title="struct std::time::Instant">Instant</a>,
|
|
) -> <a class="struct" href="struct.WaitTimeoutResult.html" title="struct parking_lot::WaitTimeoutResult">WaitTimeoutResult</a></h4></section></summary><div class="docblock"><p>Waits on this condition variable for a notification, timing out after
|
|
the specified time instant.</p>
|
|
<p>The semantics of this function are equivalent to <code>wait()</code> except that
|
|
the thread will be blocked roughly until <code>timeout</code> is reached. This
|
|
method should not be used for precise timing due to anomalies such as
|
|
preemption or platform differences that may not cause the maximum
|
|
amount of time waited to be precisely <code>timeout</code>.</p>
|
|
<p>Note that the best effort is made to ensure that the time waited is
|
|
measured with a monotonic clock, and not affected by the changes made to
|
|
the system time.</p>
|
|
<p>The returned <code>WaitTimeoutResult</code> value indicates if the timeout is
|
|
known to have elapsed.</p>
|
|
<p>Like <code>wait</code>, the lock specified will be re-acquired when this function
|
|
returns, regardless of whether the timeout elapsed or not.</p>
|
|
<h5 id="panics-1"><a class="doc-anchor" href="#panics-1">§</a>Panics</h5>
|
|
<p>This function will panic if another thread is waiting on the <code>Condvar</code>
|
|
with a different <code>Mutex</code> object.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.wait_for" class="method"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#381-388">Source</a><h4 class="code-header">pub fn <a href="#method.wait_for" class="fn">wait_for</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(
|
|
&self,
|
|
mutex_guard: &mut <a class="type" href="type.MutexGuard.html" title="type parking_lot::MutexGuard">MutexGuard</a><'_, T>,
|
|
timeout: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>,
|
|
) -> <a class="struct" href="struct.WaitTimeoutResult.html" title="struct parking_lot::WaitTimeoutResult">WaitTimeoutResult</a></h4></section></summary><div class="docblock"><p>Waits on this condition variable for a notification, timing out after a
|
|
specified duration.</p>
|
|
<p>The semantics of this function are equivalent to <code>wait()</code> except that
|
|
the thread will be blocked for roughly no longer than <code>timeout</code>. This
|
|
method should not be used for precise timing due to anomalies such as
|
|
preemption or platform differences that may not cause the maximum
|
|
amount of time waited to be precisely <code>timeout</code>.</p>
|
|
<p>Note that the best effort is made to ensure that the time waited is
|
|
measured with a monotonic clock, and not affected by the changes made to
|
|
the system time.</p>
|
|
<p>The returned <code>WaitTimeoutResult</code> value indicates if the timeout is
|
|
known to have elapsed.</p>
|
|
<p>Like <code>wait</code>, the lock specified will be re-acquired when this function
|
|
returns, regardless of whether the timeout elapsed or not.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.wait_while" class="method"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#427-433">Source</a><h4 class="code-header">pub fn <a href="#method.wait_while" class="fn">wait_while</a><T, F>(
|
|
&self,
|
|
mutex_guard: &mut <a class="type" href="type.MutexGuard.html" title="type parking_lot::MutexGuard">MutexGuard</a><'_, T>,
|
|
condition: F,
|
|
)<div class="where">where
|
|
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
|
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&mut T</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>,</div></h4></section></summary><div class="docblock"><p>Blocks the current thread until this condition variable receives a
|
|
notification. If the provided condition evaluates to <code>false</code>, then the
|
|
thread is no longer blocked and the operation is completed. If the
|
|
condition evaluates to <code>true</code>, then the thread is blocked again and
|
|
waits for another notification before repeating this process.</p>
|
|
<p>This function will atomically unlock the mutex specified (represented by
|
|
<code>mutex_guard</code>) and block the current thread. This means that any calls
|
|
to <code>notify_*()</code> which happen logically after the mutex is unlocked are
|
|
candidates to wake this thread up. When this function call returns, the
|
|
lock specified will have been re-acquired.</p>
|
|
<h5 id="panics-2"><a class="doc-anchor" href="#panics-2">§</a>Panics</h5>
|
|
<p>This function will panic if another thread is waiting on the <code>Condvar</code>
|
|
with a different <code>Mutex</code> object.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.wait_while_until" class="method"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#463-474">Source</a><h4 class="code-header">pub fn <a href="#method.wait_while_until" class="fn">wait_while_until</a><T, F>(
|
|
&self,
|
|
mutex_guard: &mut <a class="type" href="type.MutexGuard.html" title="type parking_lot::MutexGuard">MutexGuard</a><'_, T>,
|
|
condition: F,
|
|
timeout: <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/time/struct.Instant.html" title="struct std::time::Instant">Instant</a>,
|
|
) -> <a class="struct" href="struct.WaitTimeoutResult.html" title="struct parking_lot::WaitTimeoutResult">WaitTimeoutResult</a><div class="where">where
|
|
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
|
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&mut T</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>,</div></h4></section></summary><div class="docblock"><p>Waits on this condition variable for a notification, timing out after
|
|
the specified time instant. If the provided condition evaluates to
|
|
<code>false</code>, then the thread is no longer blocked and the operation is
|
|
completed. If the condition evaluates to <code>true</code>, then the thread is
|
|
blocked again and waits for another notification before repeating
|
|
this process.</p>
|
|
<p>The semantics of this function are equivalent to <code>wait()</code> except that
|
|
the thread will be blocked roughly until <code>timeout</code> is reached. This
|
|
method should not be used for precise timing due to anomalies such as
|
|
preemption or platform differences that may not cause the maximum
|
|
amount of time waited to be precisely <code>timeout</code>.</p>
|
|
<p>Note that the best effort is made to ensure that the time waited is
|
|
measured with a monotonic clock, and not affected by the changes made to
|
|
the system time.</p>
|
|
<p>The returned <code>WaitTimeoutResult</code> value indicates if the timeout is
|
|
known to have elapsed.</p>
|
|
<p>Like <code>wait</code>, the lock specified will be re-acquired when this function
|
|
returns, regardless of whether the timeout elapsed or not.</p>
|
|
<h5 id="panics-3"><a class="doc-anchor" href="#panics-3">§</a>Panics</h5>
|
|
<p>This function will panic if another thread is waiting on the <code>Condvar</code>
|
|
with a different <code>Mutex</code> object.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.wait_while_for" class="method"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#498-509">Source</a><h4 class="code-header">pub fn <a href="#method.wait_while_for" class="fn">wait_while_for</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, F>(
|
|
&self,
|
|
mutex_guard: &mut <a class="type" href="type.MutexGuard.html" title="type parking_lot::MutexGuard">MutexGuard</a><'_, T>,
|
|
condition: F,
|
|
timeout: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>,
|
|
) -> <a class="struct" href="struct.WaitTimeoutResult.html" title="struct parking_lot::WaitTimeoutResult">WaitTimeoutResult</a><div class="where">where
|
|
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&mut T</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>,</div></h4></section></summary><div class="docblock"><p>Waits on this condition variable for a notification, timing out after a
|
|
specified duration. If the provided condition evaluates to <code>false</code>,
|
|
then the thread is no longer blocked and the operation is completed.
|
|
If the condition evaluates to <code>true</code>, then the thread is blocked again
|
|
and waits for another notification before repeating this process.</p>
|
|
<p>The semantics of this function are equivalent to <code>wait()</code> except that
|
|
the thread will be blocked for roughly no longer than <code>timeout</code>. This
|
|
method should not be used for precise timing due to anomalies such as
|
|
preemption or platform differences that may not cause the maximum
|
|
amount of time waited to be precisely <code>timeout</code>.</p>
|
|
<p>Note that the best effort is made to ensure that the time waited is
|
|
measured with a monotonic clock, and not affected by the changes made to
|
|
the system time.</p>
|
|
<p>The returned <code>WaitTimeoutResult</code> value indicates if the timeout is
|
|
known to have elapsed.</p>
|
|
<p>Like <code>wait</code>, the lock specified will be re-acquired when this function
|
|
returns, regardless of whether the timeout elapsed or not.</p>
|
|
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Condvar" class="impl"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#519-523">Source</a><a href="#impl-Debug-for-Condvar" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Condvar.html" title="struct parking_lot::Condvar">Condvar</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/parking_lot/condvar.rs.html#520-522">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.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.93.1/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.93.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.93.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-Default-for-Condvar" class="impl"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#512-517">Source</a><a href="#impl-Default-for-Condvar" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="struct.Condvar.html" title="struct parking_lot::Condvar">Condvar</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.default" class="method trait-impl"><a class="src rightside" href="../src/parking_lot/condvar.rs.html#514-516">Source</a><a href="#method.default" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/default/trait.Default.html#tymethod.default" class="fn">default</a>() -> <a class="struct" href="struct.Condvar.html" title="struct parking_lot::Condvar">Condvar</a></h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a href="https://doc.rust-lang.org/1.93.1/core/default/trait.Default.html#tymethod.default">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Condvar" class="impl"><a href="#impl-Freeze-for-Condvar" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Condvar.html" title="struct parking_lot::Condvar">Condvar</a></h3></section><section id="impl-RefUnwindSafe-for-Condvar" class="impl"><a href="#impl-RefUnwindSafe-for-Condvar" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Condvar.html" title="struct parking_lot::Condvar">Condvar</a></h3></section><section id="impl-Send-for-Condvar" class="impl"><a href="#impl-Send-for-Condvar" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Condvar.html" title="struct parking_lot::Condvar">Condvar</a></h3></section><section id="impl-Sync-for-Condvar" class="impl"><a href="#impl-Sync-for-Condvar" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Condvar.html" title="struct parking_lot::Condvar">Condvar</a></h3></section><section id="impl-Unpin-for-Condvar" class="impl"><a href="#impl-Unpin-for-Condvar" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Condvar.html" title="struct parking_lot::Condvar">Condvar</a></h3></section><section id="impl-UnwindSafe-for-Condvar" class="impl"><a href="#impl-UnwindSafe-for-Condvar" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Condvar.html" title="struct parking_lot::Condvar">Condvar</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.93.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.93.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.93.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.93.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.93.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.93.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.93.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.93.1/src/core/borrow.rs.html#212">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.93.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.93.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.93.1/src/core/borrow.rs.html#214">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.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.93.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.93.1/src/core/borrow.rs.html#221">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.93.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.93.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.93.1/src/core/borrow.rs.html#222">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.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.93.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.93.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.93.1/src/core/convert/mod.rs.html#785">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.93.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.93.1/src/core/convert/mod.rs.html#788">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.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.93.1/src/core/convert/mod.rs.html#767-769">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.93.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.93.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.93.1/src/core/convert/mod.rs.html#777">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.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.93.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.93.1/src/core/convert/mod.rs.html#827-829">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.93.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.93.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.93.1/src/core/convert/mod.rs.html#831">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.93.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.93.1/src/core/convert/mod.rs.html#834">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.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.93.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.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.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.93.1/src/core/convert/mod.rs.html#811-813">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.93.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.93.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.93.1/src/core/convert/mod.rs.html#815">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.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.93.1/src/core/convert/mod.rs.html#818">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.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.93.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.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.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> |