<!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="API documentation for the Rust `sync` mod in crate `std`."> <meta name="keywords" content="rust, rustlang, rust-lang, sync"> <title>std::sync - Rust</title> <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="../../dark.css"> <link rel="stylesheet" type="text/css" href="../../main.css" id="themeStyle"> <script src="../../storage.js"></script> <link rel="shortcut icon" href="https://doc.rust-lang.org/favicon.ico"> </head> <body class="rustdoc mod"> <!--[if lte IE 8]> <div class="warning"> This old browser is unsupported and will most likely display funky things. </div> <![endif]--> <nav class="sidebar"> <div class="sidebar-menu">☰</div> <a href='../../std/index.html'><img src='https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='logo' width='100'></a> <p class='location'>Module sync</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#constants">Constants</a></li><li><a href="#types">Type Definitions</a></li></ul></div><p class='location'><a href='../index.html'>std</a></p><script>window.sidebarCurrent = {name: 'sync', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div> </nav> <div class="theme-picker"> <button id="theme-picker" aria-label="Pick another theme!"> <img src="../../brush.svg" width="18" alt="Pick another theme!"> </button> <div id="theme-choices"></div> </div> <script src="../../theme.js"></script> <nav class="sub"> <form class="search-form js-only"> <div class="search-container"> <input class="search-input" name="search" autocomplete="off" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"> </div> </form> </nav> <section id='main' class="content"> <h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>std</a>::<wbr><a class="mod" href=''>sync</a></span><span class='out-of-band'><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><span id='render-detail'> <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs"> [<span class='inner'>−</span>] </a> </span><a class='srclink' href='../../src/std/sync/mod.rs.html#11-44' title='goto source code'>[src]</a></span></h1> <div class='docblock'><p>Useful synchronization primitives.</p> <p>This module contains useful safe and unsafe synchronization primitives. Most of the primitives in this module do not provide any sort of locking and/or blocking at all, but rather provide the necessary tools to build other types of concurrent primitives.</p> </div><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2> <table> <tr class=' module-item'> <td><a class="mod" href="atomic/index.html" title='mod std::sync::atomic'>atomic</a></td> <td class='docblock-short'> <p>Atomic types</p> </td> </tr> <tr class=' module-item'> <td><a class="mod" href="mpsc/index.html" title='mod std::sync::mpsc'>mpsc</a></td> <td class='docblock-short'> <p>Multi-producer, single-consumer FIFO queue communication primitives.</p> </td> </tr></table><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2> <table> <tr class=' module-item'> <td><a class="struct" href="struct.Arc.html" title='struct std::sync::Arc'>Arc</a></td> <td class='docblock-short'> <p>A thread-safe reference-counting pointer. 'Arc' stands for 'Atomically Reference Counted'.</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.Barrier.html" title='struct std::sync::Barrier'>Barrier</a></td> <td class='docblock-short'> <p>A barrier enables multiple threads to synchronize the beginning of some computation.</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.BarrierWaitResult.html" title='struct std::sync::BarrierWaitResult'>BarrierWaitResult</a></td> <td class='docblock-short'> <p>A <code>BarrierWaitResult</code> is returned by <a href="struct.Barrier.html#method.wait"><code>wait</code></a> when all threads in the <a href="struct.Barrier.html"><code>Barrier</code></a> have rendezvoused.</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.Condvar.html" title='struct std::sync::Condvar'>Condvar</a></td> <td class='docblock-short'> <p>A Condition Variable</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.Mutex.html" title='struct std::sync::Mutex'>Mutex</a></td> <td class='docblock-short'> <p>A mutual exclusion primitive useful for protecting shared data</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.MutexGuard.html" title='struct std::sync::MutexGuard'>MutexGuard</a></td> <td class='docblock-short'> <p>An RAII implementation of a "scoped lock" of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.Once.html" title='struct std::sync::Once'>Once</a></td> <td class='docblock-short'> <p>A synchronization primitive which can be used to run a one-time global initialization. Useful for one-time initialization for FFI or related functionality. This type can only be constructed with the <a href="constant.ONCE_INIT.html"><code>ONCE_INIT</code></a> value.</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.PoisonError.html" title='struct std::sync::PoisonError'>PoisonError</a></td> <td class='docblock-short'> <p>A type of error which can be returned whenever a lock is acquired.</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.RwLock.html" title='struct std::sync::RwLock'>RwLock</a></td> <td class='docblock-short'> <p>A reader-writer lock</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.RwLockReadGuard.html" title='struct std::sync::RwLockReadGuard'>RwLockReadGuard</a></td> <td class='docblock-short'> <p>RAII structure used to release the shared read access of a lock when dropped.</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.RwLockWriteGuard.html" title='struct std::sync::RwLockWriteGuard'>RwLockWriteGuard</a></td> <td class='docblock-short'> <p>RAII structure used to release the exclusive write access of a lock when dropped.</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.WaitTimeoutResult.html" title='struct std::sync::WaitTimeoutResult'>WaitTimeoutResult</a></td> <td class='docblock-short'> <p>A type indicating whether a timed wait on a condition variable returned due to a time out or not.</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.Weak.html" title='struct std::sync::Weak'>Weak</a></td> <td class='docblock-short'> <p><code>Weak</code> is a version of <a href="struct.Arc.html"><code>Arc</code></a> that holds a non-owning reference to the managed value. The value is accessed by calling <a href="struct.Weak.html#method.upgrade"><code>upgrade</code></a> on the <code>Weak</code> pointer, which returns an <a href="../../std/option/enum.Option.html"><code>Option</code></a><code><</code><a href="struct.Arc.html"><code>Arc</code></a><code><T>></code>.</p> </td> </tr> <tr class='unstable module-item'> <td><a class="struct" href="struct.OnceState.html" title='struct std::sync::OnceState'>OnceState</a></td> <td class='docblock-short'> [<div class='stab unstable'>Experimental</div>] <p>State yielded to <a href="struct.Once.html#method.call_once_force"><code>call_once_force</code></a>’s closure parameter. The state can be used to query the poison status of the <a href="struct.Once.html"><code>Once</code></a>.</p> </td> </tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2> <table> <tr class=' module-item'> <td><a class="enum" href="enum.TryLockError.html" title='enum std::sync::TryLockError'>TryLockError</a></td> <td class='docblock-short'> <p>An enumeration of possible errors associated with a <a href="type.TryLockResult.html"><code>TryLockResult</code></a> which can occur while trying to aquire a lock, from the <a href="struct.Mutex.html#method.try_lock"><code>try_lock</code></a> method on a <a href="struct.Mutex.html"><code>Mutex</code></a> or the <a href="struct.RwLock.html#method.try_read"><code>try_read</code></a> and <a href="struct.RwLock.html#method.try_write"><code>try_write</code></a> methods on an <a href="struct.RwLock.html"><code>RwLock</code></a>.</p> </td> </tr></table><h2 id='constants' class='section-header'><a href="#constants">Constants</a></h2> <table> <tr class=' module-item'> <td><a class="constant" href="constant.ONCE_INIT.html" title='constant std::sync::ONCE_INIT'>ONCE_INIT</a></td> <td class='docblock-short'> <p>Initialization value for static <a href="struct.Once.html"><code>Once</code></a> values.</p> </td> </tr></table><h2 id='types' class='section-header'><a href="#types">Type Definitions</a></h2> <table> <tr class=' module-item'> <td><a class="type" href="type.LockResult.html" title='type std::sync::LockResult'>LockResult</a></td> <td class='docblock-short'> <p>A type alias for the result of a lock method which can be poisoned.</p> </td> </tr> <tr class=' module-item'> <td><a class="type" href="type.TryLockResult.html" title='type std::sync::TryLockResult'>TryLockResult</a></td> <td class='docblock-short'> <p>A type alias for the result of a nonblocking locking method.</p> </td> </tr></table></section> <section id='search' class="content hidden"></section> <section class="footer"></section> <aside id="help" class="hidden"> <div> <h1 class="hidden">Help</h1> <div class="shortcuts"> <h2>Keyboard Shortcuts</h2> <dl> <dt><kbd>?</kbd></dt> <dd>Show this help dialog</dd> <dt><kbd>S</kbd></dt> <dd>Focus the search field</dd> <dt><kbd>↑</kbd></dt> <dd>Move up in search results</dd> <dt><kbd>↓</kbd></dt> <dd>Move down in search results</dd> <dt><kbd>↹</kbd></dt> <dd>Switch tab</dd> <dt><kbd>⏎</kbd></dt> <dd>Go to active search result</dd> <dt><kbd>+</kbd></dt> <dd>Expand all sections</dd> <dt><kbd>-</kbd></dt> <dd>Collapse all sections</dd> </dl> </div> <div class="infos"> <h2>Search Tricks</h2> <p> Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type. </p> <p> Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>. </p> <p> Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>) </p> </div> </div> </aside> <script> window.rootPath = "../../"; window.currentCrate = "std"; </script> <script src="../../main.js"></script> <script defer src="../../search-index.js"></script> </body> </html>