oxipng/doc/crossbeam/mem/epoch/struct.Atomic.html
2016-04-08 13:52:15 -04:00

180 lines
No EOL
17 KiB
HTML
Raw 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="API documentation for the Rust `Atomic` struct in crate `crossbeam`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Atomic">
<title>crossbeam::mem::epoch::Atomic - Rust</title>
<link rel="stylesheet" type="text/css" href="../../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../../index.html'>crossbeam</a>::<wbr><a href='../index.html'>mem</a>::<wbr><a href='index.html'>epoch</a></p><script>window.sidebarCurrent = {name: 'Atomic', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<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 struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='../../index.html'>crossbeam</a>::<wbr><a href='../index.html'>mem</a>::<wbr><a href='index.html'>epoch</a>::<wbr><a class='struct' href=''>Atomic</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-18' class='srclink' href='../../../src/crossbeam/mem/epoch/atomic.rs.html#12-15' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Atomic&lt;T&gt; {
// some fields omitted
}</pre><div class='docblock'><p>Like <code>std::sync::atomic::AtomicPtr</code>.</p>
<p>Provides atomic access to a (nullable) pointer of type <code>T</code>, interfacing with
the <code>Owned</code> and <code>Shared</code> types.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><code>impl&lt;T&gt; <a class='struct' href='../../../crossbeam/mem/epoch/struct.Atomic.html' title='crossbeam::mem::epoch::Atomic'>Atomic</a>&lt;T&gt;</code></h3><div class='impl-items'><h4 id='method.null' class='method'><code>fn <a href='#method.null' class='fnname'>null</a>() -&gt; <a class='struct' href='../../../crossbeam/mem/epoch/struct.Atomic.html' title='crossbeam::mem::epoch::Atomic'>Atomic</a>&lt;T&gt;</code></h4>
<h4 id='method.new' class='method'><code>fn <a href='#method.new' class='fnname'>new</a>(data: T) -&gt; <a class='struct' href='../../../crossbeam/mem/epoch/struct.Atomic.html' title='crossbeam::mem::epoch::Atomic'>Atomic</a>&lt;T&gt;</code></h4>
<div class='docblock'><p>Create a new atomic pointer</p>
</div><h4 id='method.load' class='method'><code>fn <a href='#method.load' class='fnname'>load</a>&lt;'a&gt;(&amp;self, ord: <a class='enum' href='https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html' title='core::sync::atomic::Ordering'>Ordering</a>, _: &amp;'a <a class='struct' href='../../../crossbeam/mem/epoch/struct.Guard.html' title='crossbeam::mem::epoch::Guard'>Guard</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Shared.html' title='crossbeam::mem::epoch::Shared'>Shared</a>&lt;'a, T&gt;&gt;</code></h4>
<div class='docblock'><p>Do an atomic load with the given memory ordering.</p>
<p>In order to perform the load, we must pass in a borrow of a
<code>Guard</code>. This is a way of guaranteeing that the thread has pinned the
epoch for the entire lifetime <code>&#39;a</code>. In return, you get an optional
<code>Shared</code> pointer back (<code>None</code> if the <code>Atomic</code> is currently null), with
lifetime tied to the guard.</p>
<h1 id='panics' class='section-header'><a href='#panics'>Panics</a></h1>
<p>Panics if <code>ord</code> is <code>Release</code> or <code>AcqRel</code>.</p>
</div><h4 id='method.store' class='method'><code>fn <a href='#method.store' class='fnname'>store</a>(&amp;self, val: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Owned.html' title='crossbeam::mem::epoch::Owned'>Owned</a>&lt;T&gt;&gt;, ord: <a class='enum' href='https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html' title='core::sync::atomic::Ordering'>Ordering</a>)</code></h4>
<div class='docblock'><p>Do an atomic store with the given memory ordering.</p>
<p>Transfers ownership of the given <code>Owned</code> pointer, if any. Since no
lifetime information is acquired, no <code>Guard</code> value is needed.</p>
<h1 id='panics-1' class='section-header'><a href='#panics-1'>Panics</a></h1>
<p>Panics if <code>ord</code> is <code>Acquire</code> or <code>AcqRel</code>.</p>
</div><h4 id='method.store_and_ref' class='method'><code>fn <a href='#method.store_and_ref' class='fnname'>store_and_ref</a>&lt;'a&gt;(&amp;self, val: <a class='struct' href='../../../crossbeam/mem/epoch/struct.Owned.html' title='crossbeam::mem::epoch::Owned'>Owned</a>&lt;T&gt;, ord: <a class='enum' href='https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html' title='core::sync::atomic::Ordering'>Ordering</a>, _: &amp;'a <a class='struct' href='../../../crossbeam/mem/epoch/struct.Guard.html' title='crossbeam::mem::epoch::Guard'>Guard</a>) -&gt; <a class='struct' href='../../../crossbeam/mem/epoch/struct.Shared.html' title='crossbeam::mem::epoch::Shared'>Shared</a>&lt;'a, T&gt;</code></h4>
<div class='docblock'><p>Do an atomic store with the given memory ordering, immediately yielding
a shared reference to the pointer that was stored.</p>
<p>Transfers ownership of the given <code>Owned</code> pointer, yielding a <code>Shared</code>
reference to it. Since the reference is valid only for the curent epoch,
it&#39;s lifetime is tied to a <code>Guard</code> value.</p>
<h1 id='panics-2' class='section-header'><a href='#panics-2'>Panics</a></h1>
<p>Panics if <code>ord</code> is <code>Acquire</code> or <code>AcqRel</code>.</p>
</div><h4 id='method.store_shared' class='method'><code>fn <a href='#method.store_shared' class='fnname'>store_shared</a>(&amp;self, val: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Shared.html' title='crossbeam::mem::epoch::Shared'>Shared</a>&lt;T&gt;&gt;, ord: <a class='enum' href='https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html' title='core::sync::atomic::Ordering'>Ordering</a>)</code></h4>
<div class='docblock'><p>Do an atomic store of a <code>Shared</code> pointer with the given memory ordering.</p>
<p>This operation does not require a guard, because it does not yield any
new information about the lifetime of a pointer.</p>
<h1 id='panics-3' class='section-header'><a href='#panics-3'>Panics</a></h1>
<p>Panics if <code>ord</code> is <code>Acquire</code> or <code>AcqRel</code>.</p>
</div><h4 id='method.cas' class='method'><code>fn <a href='#method.cas' class='fnname'>cas</a>(&amp;self, old: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Shared.html' title='crossbeam::mem::epoch::Shared'>Shared</a>&lt;T&gt;&gt;, new: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Owned.html' title='crossbeam::mem::epoch::Owned'>Owned</a>&lt;T&gt;&gt;, ord: <a class='enum' href='https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html' title='core::sync::atomic::Ordering'>Ordering</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>, <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Owned.html' title='crossbeam::mem::epoch::Owned'>Owned</a>&lt;T&gt;&gt;&gt;</code></h4>
<div class='docblock'><p>Do a compare-and-set from a <code>Shared</code> to an <code>Owned</code> pointer with the
given memory ordering.</p>
<p>As with <code>store</code>, this operation does not require a guard; it produces no new
lifetime information. The <code>Result</code> indicates whether the CAS succeeded; if
not, ownership of the <code>new</code> pointer is returned to the caller.</p>
</div><h4 id='method.cas_and_ref' class='method'><code>fn <a href='#method.cas_and_ref' class='fnname'>cas_and_ref</a>&lt;'a&gt;(&amp;self, old: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Shared.html' title='crossbeam::mem::epoch::Shared'>Shared</a>&lt;T&gt;&gt;, new: <a class='struct' href='../../../crossbeam/mem/epoch/struct.Owned.html' title='crossbeam::mem::epoch::Owned'>Owned</a>&lt;T&gt;, ord: <a class='enum' href='https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html' title='core::sync::atomic::Ordering'>Ordering</a>, _: &amp;'a <a class='struct' href='../../../crossbeam/mem/epoch/struct.Guard.html' title='crossbeam::mem::epoch::Guard'>Guard</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Shared.html' title='crossbeam::mem::epoch::Shared'>Shared</a>&lt;'a, T&gt;, <a class='struct' href='../../../crossbeam/mem/epoch/struct.Owned.html' title='crossbeam::mem::epoch::Owned'>Owned</a>&lt;T&gt;&gt;</code></h4>
<div class='docblock'><p>Do a compare-and-set from a <code>Shared</code> to an <code>Owned</code> pointer with the
given memory ordering, immediatley acquiring a new <code>Shared</code> reference to
the previously-owned pointer if successful.</p>
<p>This operation is analogous to <code>store_and_ref</code>.</p>
</div><h4 id='method.cas_shared' class='method'><code>fn <a href='#method.cas_shared' class='fnname'>cas_shared</a>(&amp;self, old: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Shared.html' title='crossbeam::mem::epoch::Shared'>Shared</a>&lt;T&gt;&gt;, new: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Shared.html' title='crossbeam::mem::epoch::Shared'>Shared</a>&lt;T&gt;&gt;, ord: <a class='enum' href='https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html' title='core::sync::atomic::Ordering'>Ordering</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>Do a compare-and-set from a <code>Shared</code> to another <code>Shared</code> pointer with
the given memory ordering.</p>
<p>The boolean return value is <code>true</code> when the CAS is successful.</p>
</div><h4 id='method.swap' class='method'><code>fn <a href='#method.swap' class='fnname'>swap</a>&lt;'a&gt;(&amp;self, new: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Owned.html' title='crossbeam::mem::epoch::Owned'>Owned</a>&lt;T&gt;&gt;, ord: <a class='enum' href='https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html' title='core::sync::atomic::Ordering'>Ordering</a>, _: &amp;'a <a class='struct' href='../../../crossbeam/mem/epoch/struct.Guard.html' title='crossbeam::mem::epoch::Guard'>Guard</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Shared.html' title='crossbeam::mem::epoch::Shared'>Shared</a>&lt;'a, T&gt;&gt;</code></h4>
<div class='docblock'><p>Do an atomic swap with an <code>Owned</code> pointer with the given memory ordering.</p>
</div><h4 id='method.swap_shared' class='method'><code>fn <a href='#method.swap_shared' class='fnname'>swap_shared</a>&lt;'a&gt;(&amp;self, new: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Shared.html' title='crossbeam::mem::epoch::Shared'>Shared</a>&lt;T&gt;&gt;, ord: <a class='enum' href='https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html' title='core::sync::atomic::Ordering'>Ordering</a>, _: &amp;'a <a class='struct' href='../../../crossbeam/mem/epoch/struct.Guard.html' title='crossbeam::mem::epoch::Guard'>Guard</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../../crossbeam/mem/epoch/struct.Shared.html' title='crossbeam::mem::epoch::Shared'>Shared</a>&lt;'a, T&gt;&gt;</code></h4>
<div class='docblock'><p>Do an atomic swap with a <code>Shared</code> pointer with the given memory ordering.</p>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><code>impl&lt;T: <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html' title='core::marker::Sync'>Sync</a>&gt; <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Send.html' title='core::marker::Send'>Send</a> for <a class='struct' href='../../../crossbeam/mem/epoch/struct.Atomic.html' title='crossbeam::mem::epoch::Atomic'>Atomic</a>&lt;T&gt;</code></h3><div class='impl-items'></div><h3 class='impl'><code>impl&lt;T: <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html' title='core::marker::Sync'>Sync</a>&gt; <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html' title='core::marker::Sync'>Sync</a> for <a class='struct' href='../../../crossbeam/mem/epoch/struct.Atomic.html' title='crossbeam::mem::epoch::Atomic'>Atomic</a>&lt;T&gt;</code></h3><div class='impl-items'></div></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>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</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 = "crossbeam";
window.playgroundUrl = "";
</script>
<script src="../../../jquery.js"></script>
<script src="../../../main.js"></script>
<script defer src="../../../search-index.js"></script>
</body>
</html>