Files
phy/async_lock/index.html
Orion Kindel 0ce894e6b0 doc
2025-03-18 10:30:23 -05:00

25 lines
10 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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="Async synchronization primitives."><title>async_lock - 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="async_lock" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png"></head><body class="rustdoc mod crate"><!--[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><a class="logo-container" href="../async_lock/index.html"><img src="https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../async_lock/index.html"><img src="https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png" alt="logo"></a><h2><a href="../async_lock/index.html">async_<wbr>lock</a><span class="version">3.4.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#relationship-with-stdsync" title="Relationship with `std::sync`">Relationship with <code>std::sync</code></a></li></ul><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"></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"><h1>Crate <span>async_lock</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/async_lock/lib.rs.html#1-168">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Async synchronization primitives.</p>
<p>This crate provides the following primitives:</p>
<ul>
<li><a href="struct.Barrier.html" title="struct async_lock::Barrier"><code>Barrier</code></a> - enables tasks to synchronize all together at the same time.</li>
<li><a href="struct.Mutex.html" title="struct async_lock::Mutex"><code>Mutex</code></a> - a mutual exclusion lock.</li>
<li><a href="struct.RwLock.html" title="struct async_lock::RwLock"><code>RwLock</code></a> - a reader-writer lock, allowing any number of readers or a single writer.</li>
<li><a href="struct.Semaphore.html" title="struct async_lock::Semaphore"><code>Semaphore</code></a> - limits the number of concurrent operations.</li>
</ul>
<h3 id="relationship-with-stdsync"><a class="doc-anchor" href="#relationship-with-stdsync">§</a>Relationship with <code>std::sync</code></h3>
<p>In general, you should consider using <a href="https://doc.rust-lang.org/std/sync/index.html"><code>std::sync</code></a> types over types from this crate.</p>
<p>There are two primary use cases for types from this crate:</p>
<ul>
<li>You need to use a synchronization primitive in a <code>no_std</code> environment.</li>
<li>You need to hold a lock across an <code>.await</code> point.
(Holding an <a href="https://doc.rust-lang.org/std/sync/index.html"><code>std::sync</code></a> lock guard across an <code>.await</code> will make your future non-<code>Send</code>,
and is also highly likely to cause deadlocks.)</li>
</ul>
<p>If you already use <code>libstd</code> and you arent holding locks across await points (there is a
Clippy lint called <a href="https://rust-lang.github.io/rust-clippy/stable/index.html#/await_holding_lock"><code>await_holding_lock</code></a> that emits warnings for this scenario), you should
consider <a href="https://doc.rust-lang.org/std/sync/index.html"><code>std::sync</code></a> instead of this crate. Those types are optimized for the currently
running operating system, are less complex and are generally much faster.</p>
<p>In contrast, <code>async-lock</code>s notification system uses <code>std::sync::Mutex</code> under the hood if
the <code>std</code> feature is enabled, and will fall back to a significantly slower strategy if it is
not. So, there are few cases where <code>async-lock</code> is a win for performance over <a href="https://doc.rust-lang.org/std/sync/index.html"><code>std::sync</code></a>.</p>
</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="futures/index.html" title="mod async_lock::futures">futures</a></div><div class="desc docblock-short">Named futures for use with <code>async_lock</code> primitives.</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.Barrier.html" title="struct async_lock::Barrier">Barrier</a></div><div class="desc docblock-short">A counter to synchronize multiple tasks at the same time.</div></li><li><div class="item-name"><a class="struct" href="struct.BarrierWaitResult.html" title="struct async_lock::BarrierWaitResult">Barrier<wbr>Wait<wbr>Result</a></div><div class="desc docblock-short">Returned by <a href="struct.Barrier.html#method.wait" title="method async_lock::Barrier::wait"><code>Barrier::wait()</code></a> when all tasks have called it.</div></li><li><div class="item-name"><a class="struct" href="struct.Mutex.html" title="struct async_lock::Mutex">Mutex</a></div><div class="desc docblock-short">An async mutex.</div></li><li><div class="item-name"><a class="struct" href="struct.MutexGuard.html" title="struct async_lock::MutexGuard">Mutex<wbr>Guard</a></div><div class="desc docblock-short">A guard that releases the mutex when dropped.</div></li><li><div class="item-name"><a class="struct" href="struct.MutexGuardArc.html" title="struct async_lock::MutexGuardArc">Mutex<wbr>Guard<wbr>Arc</a></div><div class="desc docblock-short">An owned guard that releases the mutex when dropped.</div></li><li><div class="item-name"><a class="struct" href="struct.OnceCell.html" title="struct async_lock::OnceCell">Once<wbr>Cell</a></div><div class="desc docblock-short">A memory location that can be written to at most once.</div></li><li><div class="item-name"><a class="struct" href="struct.RwLock.html" title="struct async_lock::RwLock">RwLock</a></div><div class="desc docblock-short">An async reader-writer lock.</div></li><li><div class="item-name"><a class="struct" href="struct.RwLockReadGuard.html" title="struct async_lock::RwLockReadGuard">RwLock<wbr>Read<wbr>Guard</a></div><div class="desc docblock-short">A guard that releases the read lock when dropped.</div></li><li><div class="item-name"><a class="struct" href="struct.RwLockReadGuardArc.html" title="struct async_lock::RwLockReadGuardArc">RwLock<wbr>Read<wbr>Guard<wbr>Arc</a></div><div class="desc docblock-short">An owned, reference-counting guard that releases the read lock when dropped.</div></li><li><div class="item-name"><a class="struct" href="struct.RwLockUpgradableReadGuard.html" title="struct async_lock::RwLockUpgradableReadGuard">RwLock<wbr>Upgradable<wbr>Read<wbr>Guard</a></div><div class="desc docblock-short">A guard that releases the upgradable read lock when dropped.</div></li><li><div class="item-name"><a class="struct" href="struct.RwLockUpgradableReadGuardArc.html" title="struct async_lock::RwLockUpgradableReadGuardArc">RwLock<wbr>Upgradable<wbr>Read<wbr>Guard<wbr>Arc</a></div><div class="desc docblock-short">An owned, reference-counting guard that releases the upgradable read lock when dropped.</div></li><li><div class="item-name"><a class="struct" href="struct.RwLockWriteGuard.html" title="struct async_lock::RwLockWriteGuard">RwLock<wbr>Write<wbr>Guard</a></div><div class="desc docblock-short">A guard that releases the write lock when dropped.</div></li><li><div class="item-name"><a class="struct" href="struct.RwLockWriteGuardArc.html" title="struct async_lock::RwLockWriteGuardArc">RwLock<wbr>Write<wbr>Guard<wbr>Arc</a></div><div class="desc docblock-short">An owned, reference-counted guard that releases the write lock when dropped.</div></li><li><div class="item-name"><a class="struct" href="struct.Semaphore.html" title="struct async_lock::Semaphore">Semaphore</a></div><div class="desc docblock-short">A counter for limiting the number of concurrent operations.</div></li><li><div class="item-name"><a class="struct" href="struct.SemaphoreGuard.html" title="struct async_lock::SemaphoreGuard">Semaphore<wbr>Guard</a></div><div class="desc docblock-short">A guard that releases the acquired permit.</div></li><li><div class="item-name"><a class="struct" href="struct.SemaphoreGuardArc.html" title="struct async_lock::SemaphoreGuardArc">Semaphore<wbr>Guard<wbr>Arc</a></div><div class="desc docblock-short">An owned guard that releases the acquired permit.</div></li></ul></section></div></main></body></html>