You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rCore-Tutorial-v3-tests/ch6/spin/index.html

80 lines
12 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!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="This crate provides spin-based versions of the primitives in `std::sync` and `std::lazy`. Because synchronization is done through spinning, the primitives are suitable for use in `no_std` environments."><meta name="keywords" content="rust, rustlang, rust-lang, spin"><title>spin - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../dark.css" disabled><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script src="../crates.js"></script><script defer src="../main.js"></script>
<noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></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">&#9776;</button><a class="sidebar-logo" href="../spin/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div>
</a><h2 class="location"></h2>
</nav>
<nav class="sidebar"><a class="sidebar-logo" href="../spin/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div>
</a><h2 class="location"><a href="#">Crate spin</a></h2><div class="sidebar-elems"><div class="block"><ul><li class="version">Version 0.7.1</li><li><a id="all-types" href="all.html">All Items</a></li></div></ul><section><div class="block"><ul><li><a href="#modules">Modules</a></li></ul></div></section><div id="sidebar-vars" data-name="spin" data-ty="mod" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../spin/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="main-heading">
<h1 class="fqn"><span class="in-band">Crate <a class="mod" href="#">spin</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/spin/lib.rs.html#1-97">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>This crate provides <a href="https://en.wikipedia.org/wiki/Spinlock">spin-based</a> versions of the
primitives in <code>std::sync</code> and <code>std::lazy</code>. Because synchronization is done through spinning,
the primitives are suitable for use in <code>no_std</code> environments.</p>
<h2 id="features"><a href="#features">Features</a></h2>
<ul>
<li>
<p><code>Mutex</code>, <code>RwLock</code>, <code>Once</code>/<code>SyncOnceCell</code>, and <code>SyncLazy</code> equivalents</p>
</li>
<li>
<p>Support for <code>no_std</code> environments</p>
</li>
<li>
<p><a href="https://crates.io/crates/lock_api"><code>lock_api</code></a> compatibility</p>
</li>
<li>
<p>Upgradeable <code>RwLock</code> guards</p>
</li>
<li>
<p>Guards can be sent and shared between threads</p>
</li>
<li>
<p>Guard leaking</p>
</li>
</ul>
<h2 id="relationship-with-stdsync"><a href="#relationship-with-stdsync">Relationship with <code>std::sync</code></a></h2>
<p>While <code>spin</code> is not a drop-in replacement for <code>std::sync</code> (and
<a href="https://matklad.github.io/2020/01/02/spinlocks-considered-harmful.html">should not be considered as such</a>)
an effort is made to keep this crate reasonably consistent with <code>std::sync</code>.</p>
<p>Many of the types defined in this crate have additional capabilities when compared to <code>std::sync</code>:</p>
<ul>
<li>
<p>Because spinning does not depend on the thread-driven model of <code>std::sync</code>, guards (<a href="mutex/struct.MutexGuard.html" title="MutexGuard"><code>MutexGuard</code></a>,
<a href="rw_lock/struct.RwLockReadGuard.html" title="RwLockReadGuard"><code>RwLockReadGuard</code></a>, <a href="rw_lock/struct.RwLockWriteGuard.html" title="RwLockWriteGuard"><code>RwLockWriteGuard</code></a>, etc.) may be sent and shared between threads.</p>
</li>
<li>
<p><a href="rw_lock/struct.RwLockUpgradableGuard.html" title="RwLockUpgradableGuard"><code>RwLockUpgradableGuard</code></a> supports being upgrades into a <a href="rw_lock/struct.RwLockWriteGuard.html" title="RwLockWriteGuard"><code>RwLockWriteGuard</code></a>.</p>
</li>
<li>
<p>Guards support <a href="https://doc.rust-lang.org/nomicon/leaking.html">leaking</a>.</p>
</li>
<li>
<p><a href="once/struct.Once.html" title="Once"><code>Once</code></a> owns the value returned by its <code>call_once</code> initializer.</p>
</li>
<li>
<p><a href="rw_lock/struct.RwLock.html" title="RwLock"><code>RwLock</code></a> supports counting readers and writers.</p>
</li>
</ul>
<p>Conversely, the types in this crate do not have some of the features <code>std::sync</code> has:</p>
<ul>
<li>Locks do not track <a href="https://doc.rust-lang.org/nomicon/poisoning.html">panic poisoning</a>.</li>
</ul>
<h3 id="feature-flags"><a href="#feature-flags">Feature flags</a></h3>
<p>The crate comes with a few feature flags that you may wish to use.</p>
<ul>
<li>
<p><code>lock_api</code> enabled support for <a href="https://crates.io/crates/lock_api"><code>lock_api</code></a></p>
</li>
<li>
<p><code>ticket_mutex</code> uses a ticket lock for the implementation of <code>Mutex</code></p>
</li>
<li>
<p><code>std</code> enables support for thread yielding instead of spinning</p>
</li>
</ul>
</div></details><h2 id="reexports" class="small-section-header"><a href="#reexports">Re-exports</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left import-item"><code>pub use barrier::<a class="struct" href="barrier/struct.Barrier.html" title="struct spin::barrier::Barrier">Barrier</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use lazy::<a class="struct" href="lazy/struct.Lazy.html" title="struct spin::lazy::Lazy">Lazy</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use mutex::<a class="struct" href="mutex/struct.Mutex.html" title="struct spin::mutex::Mutex">Mutex</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use mutex::<a class="struct" href="mutex/struct.MutexGuard.html" title="struct spin::mutex::MutexGuard">MutexGuard</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use once::<a class="struct" href="once/struct.Once.html" title="struct spin::once::Once">Once</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use rw_lock::<a class="struct" href="rw_lock/struct.RwLock.html" title="struct spin::rw_lock::RwLock">RwLock</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use rw_lock::<a class="struct" href="rw_lock/struct.RwLockReadGuard.html" title="struct spin::rw_lock::RwLockReadGuard">RwLockReadGuard</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use rw_lock::<a class="struct" href="rw_lock/struct.RwLockWriteGuard.html" title="struct spin::rw_lock::RwLockWriteGuard">RwLockWriteGuard</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use rw_lock::<a class="struct" href="rw_lock/struct.RwLockUpgradableGuard.html" title="struct spin::rw_lock::RwLockUpgradableGuard">RwLockUpgradableGuard</a>;</code></div><div class="item-right docblock-short"></div></div></div><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="mod" href="barrier/index.html" title="spin::barrier mod">barrier</a></div><div class="item-right docblock-short"><p>Synchronization primitive allowing multiple threads to synchronize the
beginning of some computation.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="lazy/index.html" title="spin::lazy mod">lazy</a></div><div class="item-right docblock-short"><p>Synchronization primitives for lazy evaluation.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="mutex/index.html" title="spin::mutex mod">mutex</a></div><div class="item-right docblock-short"><p>Locks that have the same behaviour as a mutex.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="once/index.html" title="spin::once mod">once</a></div><div class="item-right docblock-short"><p>Synchronization primitives for one-time evaluation.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="rw_lock/index.html" title="spin::rw_lock mod">rw_lock</a></div><div class="item-right docblock-short"><p>A lock that provides data access to either one writer or many readers.</p>
</div></div></div></section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="spin" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.62.0-nightly (1f7fb6413 2022-04-10)" ></div>
</body></html>