362 lines
No EOL
52 KiB
HTML
362 lines
No EOL
52 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="API documentation for the Rust `Atomic` struct in crate `crossbeam_epoch`.">
|
||
<meta name="keywords" content="rust, rustlang, rust-lang, Atomic">
|
||
|
||
<title>crossbeam_epoch::Atomic - 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>
|
||
|
||
|
||
|
||
|
||
</head>
|
||
<body class="rustdoc struct">
|
||
<!--[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>
|
||
|
||
<p class='location'>Struct Atomic</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.null">null</a><a href="#method.new">new</a><a href="#method.load">load</a><a href="#method.load_consume">load_consume</a><a href="#method.store">store</a><a href="#method.swap">swap</a><a href="#method.compare_and_set">compare_and_set</a><a href="#method.compare_and_set_weak">compare_and_set_weak</a><a href="#method.fetch_and">fetch_and</a><a href="#method.fetch_or">fetch_or</a><a href="#method.fetch_xor">fetch_xor</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Debug">Debug</a><a href="#impl-Pointer">Pointer</a><a href="#impl-Clone">Clone</a><a href="#impl-Default">Default</a><a href="#impl-From%3COwned%3CT%3E%3E">From<Owned<T>></a><a href="#impl-From%3CBox%3CT%3E%3E">From<Box<T>></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-From%3CShared%3C%27g%2C%20T%3E%3E">From<Shared<'g, T>></a><a href="#impl-From%3C*const%20T%3E">From<*const T></a></div></div><p class='location'><a href='index.html'>crossbeam_epoch</a></p><script>window.sidebarCurrent = {name: 'Atomic', ty: 'struct', 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'>Struct <a href='index.html'>crossbeam_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'>−</span>]
|
||
</a>
|
||
</span><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#128-131' title='goto source code'>[src]</a></span></h1>
|
||
<pre class='rust struct'>pub struct Atomic<T> { /* fields omitted */ }</pre><div class='docblock'><p>An atomic pointer that can be safely shared between threads.</p>
|
||
<p>The pointer must be properly aligned. Since it is aligned, a tag can be stored into the unused
|
||
least significant bits of the address. More precisely, a tag should be less than <code>(1 << mem::align_of::<T>().trailing_zeros())</code>.</p>
|
||
<p>Any method that loads the pointer must be passed a reference to a <a href="struct.Guard.html"><code>Guard</code></a>.</p>
|
||
</div>
|
||
<h2 id='methods' class='small-section-header'>
|
||
Methods<a href='#methods' class='anchor'></a>
|
||
</h2>
|
||
<h3 id='impl' class='impl'><span class='in-band'><code>impl<T> <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code><a href='#impl' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#136-474' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.null' class="method"><span id='null.v' class='invisible'><code>pub fn <a href='#method.null' class='fnname'>null</a>() -> <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#155-160' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Returns a new null atomic pointer.</p>
|
||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::<span class="ident">Atomic</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="op"><</span><span class="ident">i32</span><span class="op">></span>::<span class="ident">null</span>();</pre>
|
||
</div><h4 id='method.new' class="method"><span id='new.v' class='invisible'><code>pub fn <a href='#method.new' class='fnname'>new</a>(value: T) -> <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#188-190' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Allocates <code>value</code> on the heap and returns a new atomic pointer pointing to it.</p>
|
||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::<span class="ident">Atomic</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="ident">new</span>(<span class="number">1234</span>);</pre>
|
||
</div><h4 id='method.load' class="method"><span id='load.v' class='invisible'><code>pub fn <a href='#method.load' class='fnname'>load</a><'g>(&self, ord: <a class="enum" href="https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html" title="enum core::sync::atomic::Ordering">Ordering</a>, _: &'g <a class="struct" href="../crossbeam_epoch/struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a>) -> <a class="struct" href="../crossbeam_epoch/struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><'g, T></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#209-211' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Loads a <code>Shared</code> from the atomic pointer.</p>
|
||
<p>This method takes an <a href="https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html"><code>Ordering</code></a> argument which describes the memory ordering of this
|
||
operation.</p>
|
||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">epoch</span>, <span class="ident">Atomic</span>};
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::<span class="ident">atomic</span>::<span class="ident">Ordering</span>::<span class="ident">SeqCst</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="ident">new</span>(<span class="number">1234</span>);
|
||
<span class="kw">let</span> <span class="ident">guard</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">epoch</span>::<span class="ident">pin</span>();
|
||
<span class="kw">let</span> <span class="ident">p</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">load</span>(<span class="ident">SeqCst</span>, <span class="ident">guard</span>);</pre>
|
||
</div><h4 id='method.load_consume' class="method"><span id='load_consume.v' class='invisible'><code>pub fn <a href='#method.load_consume' class='fnname'>load_consume</a><'g>(&self, _: &'g <a class="struct" href="../crossbeam_epoch/struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a>) -> <a class="struct" href="../crossbeam_epoch/struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><'g, T></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#234-236' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Loads a <code>Shared</code> from the atomic pointer using a "consume" memory ordering.</p>
|
||
<p>This is similar to the "acquire" ordering, except that an ordering is
|
||
only guaranteed with operations that "depend on" the result of the load.
|
||
However consume loads are usually much faster than acquire loads on
|
||
architectures with a weak memory model since they don't require memory
|
||
fence instructions.</p>
|
||
<p>The exact definition of "depend on" is a bit vague, but it works as you
|
||
would expect in practice since a lot of software, especially the Linux
|
||
kernel, rely on this behavior.</p>
|
||
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">epoch</span>, <span class="ident">Atomic</span>};
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="ident">new</span>(<span class="number">1234</span>);
|
||
<span class="kw">let</span> <span class="ident">guard</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">epoch</span>::<span class="ident">pin</span>();
|
||
<span class="kw">let</span> <span class="ident">p</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">load_consume</span>(<span class="ident">guard</span>);</pre>
|
||
</div><h4 id='method.store' class="method"><span id='store.v' class='invisible'><code>pub fn <a href='#method.store' class='fnname'>store</a><'g, P: <a class="trait" href="../crossbeam_epoch/trait.Pointer.html" title="trait crossbeam_epoch::Pointer">Pointer</a><T>>(&self, new: P, ord: <a class="enum" href="https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html" title="enum core::sync::atomic::Ordering">Ordering</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#255-257' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Stores a <code>Shared</code> or <code>Owned</code> pointer into the atomic pointer.</p>
|
||
<p>This method takes an <a href="https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html"><code>Ordering</code></a> argument which describes the memory ordering of this
|
||
operation.</p>
|
||
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">epoch</span>, <span class="ident">Atomic</span>, <span class="ident">Owned</span>, <span class="ident">Shared</span>};
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::<span class="ident">atomic</span>::<span class="ident">Ordering</span>::<span class="ident">SeqCst</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="ident">new</span>(<span class="number">1234</span>);
|
||
<span class="ident">a</span>.<span class="ident">store</span>(<span class="ident">Shared</span>::<span class="ident">null</span>(), <span class="ident">SeqCst</span>);
|
||
<span class="ident">a</span>.<span class="ident">store</span>(<span class="ident">Owned</span>::<span class="ident">new</span>(<span class="number">1234</span>), <span class="ident">SeqCst</span>);</pre>
|
||
</div><h4 id='method.swap' class="method"><span id='swap.v' class='invisible'><code>pub fn <a href='#method.swap' class='fnname'>swap</a><'g, P: <a class="trait" href="../crossbeam_epoch/trait.Pointer.html" title="trait crossbeam_epoch::Pointer">Pointer</a><T>>(<br> &self, <br> new: P, <br> ord: <a class="enum" href="https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html" title="enum core::sync::atomic::Ordering">Ordering</a>, <br> _: &'g <a class="struct" href="../crossbeam_epoch/struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a><br>) -> <a class="struct" href="../crossbeam_epoch/struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><'g, T></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#277-279' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Stores a <code>Shared</code> or <code>Owned</code> pointer into the atomic pointer, returning the previous
|
||
<code>Shared</code>.</p>
|
||
<p>This method takes an <a href="https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html"><code>Ordering</code></a> argument which describes the memory ordering of this
|
||
operation.</p>
|
||
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">epoch</span>, <span class="ident">Atomic</span>, <span class="ident">Owned</span>, <span class="ident">Shared</span>};
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::<span class="ident">atomic</span>::<span class="ident">Ordering</span>::<span class="ident">SeqCst</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="ident">new</span>(<span class="number">1234</span>);
|
||
<span class="kw">let</span> <span class="ident">guard</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">epoch</span>::<span class="ident">pin</span>();
|
||
<span class="kw">let</span> <span class="ident">p</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">swap</span>(<span class="ident">Shared</span>::<span class="ident">null</span>(), <span class="ident">SeqCst</span>, <span class="ident">guard</span>);</pre>
|
||
</div><h4 id='method.compare_and_set' class="method"><span id='compare_and_set.v' class='invisible'><code>pub fn <a href='#method.compare_and_set' class='fnname'>compare_and_set</a><'g, O, P>(<br> &self, <br> current: <a class="struct" href="../crossbeam_epoch/struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><T>, <br> new: P, <br> ord: O, <br> _: &'g <a class="struct" href="../crossbeam_epoch/struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../crossbeam_epoch/struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><'g, T>, <a class="struct" href="../crossbeam_epoch/struct.CompareAndSetError.html" title="struct crossbeam_epoch::CompareAndSetError">CompareAndSetError</a><'g, T, P>> <span class="where fmt-newline">where<br> O: <a class="trait" href="../crossbeam_epoch/trait.CompareAndSetOrdering.html" title="trait crossbeam_epoch::CompareAndSetOrdering">CompareAndSetOrdering</a>,<br> P: <a class="trait" href="../crossbeam_epoch/trait.Pointer.html" title="trait crossbeam_epoch::Pointer">Pointer</a><T>, </span></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#307-328' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Stores the pointer <code>new</code> (either <code>Shared</code> or <code>Owned</code>) into the atomic pointer if the current
|
||
value is the same as <code>current</code>. The tag is also taken into account, so two pointers to the
|
||
same object, but with different tags, will not be considered equal.</p>
|
||
<p>The return value is a result indicating whether the new pointer was written. On success the
|
||
pointer that was written is returned. On failure the actual current value and <code>new</code> are
|
||
returned.</p>
|
||
<p>This method takes a <a href="trait.CompareAndSetOrdering.html"><code>CompareAndSetOrdering</code></a> argument which describes the memory
|
||
ordering of this operation.</p>
|
||
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">epoch</span>, <span class="ident">Atomic</span>, <span class="ident">Owned</span>, <span class="ident">Shared</span>};
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::<span class="ident">atomic</span>::<span class="ident">Ordering</span>::<span class="ident">SeqCst</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="ident">new</span>(<span class="number">1234</span>);
|
||
|
||
<span class="kw">let</span> <span class="ident">guard</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">epoch</span>::<span class="ident">pin</span>();
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">curr</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">load</span>(<span class="ident">SeqCst</span>, <span class="ident">guard</span>);
|
||
<span class="kw">let</span> <span class="ident">res1</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">compare_and_set</span>(<span class="ident">curr</span>, <span class="ident">Shared</span>::<span class="ident">null</span>(), <span class="ident">SeqCst</span>, <span class="ident">guard</span>);
|
||
<span class="kw">let</span> <span class="ident">res2</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">compare_and_set</span>(<span class="ident">curr</span>, <span class="ident">Owned</span>::<span class="ident">new</span>(<span class="number">5678</span>), <span class="ident">SeqCst</span>, <span class="ident">guard</span>);</pre>
|
||
</div><h4 id='method.compare_and_set_weak' class="method"><span id='compare_and_set_weak.v' class='invisible'><code>pub fn <a href='#method.compare_and_set_weak' class='fnname'>compare_and_set_weak</a><'g, O, P>(<br> &self, <br> current: <a class="struct" href="../crossbeam_epoch/struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><T>, <br> new: P, <br> ord: O, <br> _: &'g <a class="struct" href="../crossbeam_epoch/struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../crossbeam_epoch/struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><'g, T>, <a class="struct" href="../crossbeam_epoch/struct.CompareAndSetError.html" title="struct crossbeam_epoch::CompareAndSetError">CompareAndSetError</a><'g, T, P>> <span class="where fmt-newline">where<br> O: <a class="trait" href="../crossbeam_epoch/trait.CompareAndSetOrdering.html" title="trait crossbeam_epoch::CompareAndSetOrdering">CompareAndSetOrdering</a>,<br> P: <a class="trait" href="../crossbeam_epoch/trait.Pointer.html" title="trait crossbeam_epoch::Pointer">Pointer</a><T>, </span></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#377-398' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Stores the pointer <code>new</code> (either <code>Shared</code> or <code>Owned</code>) into the atomic pointer if the current
|
||
value is the same as <code>current</code>. The tag is also taken into account, so two pointers to the
|
||
same object, but with different tags, will not be considered equal.</p>
|
||
<p>Unlike <a href="struct.Atomic.html#method.compare_and_set"><code>compare_and_set</code></a>, this method is allowed to spuriously fail even when comparison
|
||
succeeds, which can result in more efficient code on some platforms. The return value is a
|
||
result indicating whether the new pointer was written. On success the pointer that was
|
||
written is returned. On failure the actual current value and <code>new</code> are returned.</p>
|
||
<p>This method takes a <a href="trait.CompareAndSetOrdering.html"><code>CompareAndSetOrdering</code></a> argument which describes the memory
|
||
ordering of this operation.</p>
|
||
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">epoch</span>, <span class="ident">Atomic</span>, <span class="ident">Owned</span>, <span class="ident">Shared</span>};
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::<span class="ident">atomic</span>::<span class="ident">Ordering</span>::<span class="ident">SeqCst</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="ident">new</span>(<span class="number">1234</span>);
|
||
<span class="kw">let</span> <span class="ident">guard</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">epoch</span>::<span class="ident">pin</span>();
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">new</span> <span class="op">=</span> <span class="ident">Owned</span>::<span class="ident">new</span>(<span class="number">5678</span>);
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">ptr</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">load</span>(<span class="ident">SeqCst</span>, <span class="ident">guard</span>);
|
||
<span class="kw">loop</span> {
|
||
<span class="kw">match</span> <span class="ident">a</span>.<span class="ident">compare_and_set_weak</span>(<span class="ident">ptr</span>, <span class="ident">new</span>, <span class="ident">SeqCst</span>, <span class="ident">guard</span>) {
|
||
<span class="prelude-val">Ok</span>(<span class="ident">p</span>) <span class="op">=></span> {
|
||
<span class="ident">ptr</span> <span class="op">=</span> <span class="ident">p</span>;
|
||
<span class="kw">break</span>;
|
||
}
|
||
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=></span> {
|
||
<span class="ident">ptr</span> <span class="op">=</span> <span class="ident">err</span>.<span class="ident">current</span>;
|
||
<span class="ident">new</span> <span class="op">=</span> <span class="ident">err</span>.<span class="ident">new</span>;
|
||
}
|
||
}
|
||
}
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">curr</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">load</span>(<span class="ident">SeqCst</span>, <span class="ident">guard</span>);
|
||
<span class="kw">loop</span> {
|
||
<span class="kw">match</span> <span class="ident">a</span>.<span class="ident">compare_and_set_weak</span>(<span class="ident">curr</span>, <span class="ident">Shared</span>::<span class="ident">null</span>(), <span class="ident">SeqCst</span>, <span class="ident">guard</span>) {
|
||
<span class="prelude-val">Ok</span>(_) <span class="op">=></span> <span class="kw">break</span>,
|
||
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=></span> <span class="ident">curr</span> <span class="op">=</span> <span class="ident">err</span>.<span class="ident">current</span>,
|
||
}
|
||
}</pre>
|
||
</div><h4 id='method.fetch_and' class="method"><span id='fetch_and.v' class='invisible'><code>pub fn <a href='#method.fetch_and' class='fnname'>fetch_and</a><'g>(<br> &self, <br> val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br> ord: <a class="enum" href="https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html" title="enum core::sync::atomic::Ordering">Ordering</a>, <br> _: &'g <a class="struct" href="../crossbeam_epoch/struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a><br>) -> <a class="struct" href="../crossbeam_epoch/struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><'g, T></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#421-423' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Bitwise "and" with the current tag.</p>
|
||
<p>Performs a bitwise "and" operation on the current tag and the argument <code>val</code>, and sets the
|
||
new tag to the result. Returns the previous pointer.</p>
|
||
<p>This method takes an <a href="https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html"><code>Ordering</code></a> argument which describes the memory ordering of this
|
||
operation.</p>
|
||
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">epoch</span>, <span class="ident">Atomic</span>, <span class="ident">Shared</span>};
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::<span class="ident">atomic</span>::<span class="ident">Ordering</span>::<span class="ident">SeqCst</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="op"><</span><span class="ident">i32</span><span class="op">></span>::<span class="ident">from</span>(<span class="ident">Shared</span>::<span class="ident">null</span>().<span class="ident">with_tag</span>(<span class="number">3</span>));
|
||
<span class="kw">let</span> <span class="ident">guard</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">epoch</span>::<span class="ident">pin</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">2</span>, <span class="ident">SeqCst</span>, <span class="ident">guard</span>).<span class="ident">tag</span>(), <span class="number">3</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(<span class="ident">SeqCst</span>, <span class="ident">guard</span>).<span class="ident">tag</span>(), <span class="number">2</span>);</pre>
|
||
</div><h4 id='method.fetch_or' class="method"><span id='fetch_or.v' class='invisible'><code>pub fn <a href='#method.fetch_or' class='fnname'>fetch_or</a><'g>(<br> &self, <br> val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br> ord: <a class="enum" href="https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html" title="enum core::sync::atomic::Ordering">Ordering</a>, <br> _: &'g <a class="struct" href="../crossbeam_epoch/struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a><br>) -> <a class="struct" href="../crossbeam_epoch/struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><'g, T></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#446-448' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Bitwise "or" with the current tag.</p>
|
||
<p>Performs a bitwise "or" operation on the current tag and the argument <code>val</code>, and sets the
|
||
new tag to the result. Returns the previous pointer.</p>
|
||
<p>This method takes an <a href="https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html"><code>Ordering</code></a> argument which describes the memory ordering of this
|
||
operation.</p>
|
||
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">epoch</span>, <span class="ident">Atomic</span>, <span class="ident">Shared</span>};
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::<span class="ident">atomic</span>::<span class="ident">Ordering</span>::<span class="ident">SeqCst</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="op"><</span><span class="ident">i32</span><span class="op">></span>::<span class="ident">from</span>(<span class="ident">Shared</span>::<span class="ident">null</span>().<span class="ident">with_tag</span>(<span class="number">1</span>));
|
||
<span class="kw">let</span> <span class="ident">guard</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">epoch</span>::<span class="ident">pin</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">2</span>, <span class="ident">SeqCst</span>, <span class="ident">guard</span>).<span class="ident">tag</span>(), <span class="number">1</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(<span class="ident">SeqCst</span>, <span class="ident">guard</span>).<span class="ident">tag</span>(), <span class="number">3</span>);</pre>
|
||
</div><h4 id='method.fetch_xor' class="method"><span id='fetch_xor.v' class='invisible'><code>pub fn <a href='#method.fetch_xor' class='fnname'>fetch_xor</a><'g>(<br> &self, <br> val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br> ord: <a class="enum" href="https://doc.rust-lang.org/nightly/core/sync/atomic/enum.Ordering.html" title="enum core::sync::atomic::Ordering">Ordering</a>, <br> _: &'g <a class="struct" href="../crossbeam_epoch/struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a><br>) -> <a class="struct" href="../crossbeam_epoch/struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><'g, T></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#471-473' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Bitwise "xor" with the current tag.</p>
|
||
<p>Performs a bitwise "xor" operation on the current tag and the argument <code>val</code>, and sets the
|
||
new tag to the result. Returns the previous pointer.</p>
|
||
<p>This method takes an <a href="https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html"><code>Ordering</code></a> argument which describes the memory ordering of this
|
||
operation.</p>
|
||
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">epoch</span>, <span class="ident">Atomic</span>, <span class="ident">Shared</span>};
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::<span class="ident">atomic</span>::<span class="ident">Ordering</span>::<span class="ident">SeqCst</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="op"><</span><span class="ident">i32</span><span class="op">></span>::<span class="ident">from</span>(<span class="ident">Shared</span>::<span class="ident">null</span>().<span class="ident">with_tag</span>(<span class="number">1</span>));
|
||
<span class="kw">let</span> <span class="ident">guard</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">epoch</span>::<span class="ident">pin</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">3</span>, <span class="ident">SeqCst</span>, <span class="ident">guard</span>).<span class="ident">tag</span>(), <span class="number">1</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(<span class="ident">SeqCst</span>, <span class="ident">guard</span>).<span class="ident">tag</span>(), <span class="number">2</span>);</pre>
|
||
</div></div>
|
||
<h2 id='implementations' class='small-section-header'>
|
||
Trait Implementations<a href='#implementations' class='anchor'></a>
|
||
</h2>
|
||
<h3 id='impl-Send' class='impl'><span class='in-band'><code>impl<T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code><a href='#impl-Send' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#133' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'></div><h3 id='impl-Sync' class='impl'><span class='in-band'><code>impl<T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code><a href='#impl-Sync' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#134' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'></div><h3 id='impl-Debug' class='impl'><span class='in-band'><code>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code><a href='#impl-Debug' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#476-486' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#477-485' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||
</div></div><h3 id='impl-Pointer' class='impl'><span class='in-band'><code>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Pointer.html" title="trait core::fmt::Pointer">Pointer</a> for <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code><a href='#impl-Pointer' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#488-494' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.fmt-1' class="method"><span id='fmt.v-1' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Pointer.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#489-493' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Formats the value using the given formatter.</p>
|
||
</div></div><h3 id='impl-Clone' class='impl'><span class='in-band'><code>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code><a href='#impl-Clone' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#496-505' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.clone' class="method"><span id='clone.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&self) -> Self</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#501-504' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Returns a copy of the atomic value.</p>
|
||
<p>Note that a <code>Relaxed</code> load is used here. If you need synchronization, use it with other
|
||
atomics or fences.</p>
|
||
</div><h4 id='method.clone_from' class="method"><span id='clone_from.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</code></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/clone.rs.html#112-114' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
|
||
</div></div><h3 id='impl-Default' class='impl'><span class='in-band'><code>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code><a href='#impl-Default' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#507-511' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.default' class="method"><span id='default.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -> Self</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#508-510' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Returns the "default value" for a type. <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default">Read more</a></p>
|
||
</div></div><h3 id='impl-From%3COwned%3CT%3E%3E' class='impl'><span class='in-band'><code>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="../crossbeam_epoch/struct.Owned.html" title="struct crossbeam_epoch::Owned">Owned</a><T>> for <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code><a href='#impl-From%3COwned%3CT%3E%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#513-528' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.from' class="method"><span id='from.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(owned: <a class="struct" href="../crossbeam_epoch/struct.Owned.html" title="struct crossbeam_epoch::Owned">Owned</a><T>) -> Self</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#523-527' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Returns a new atomic pointer pointing to <code>owned</code>.</p>
|
||
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::{<span class="ident">Atomic</span>, <span class="ident">Owned</span>};
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="op"><</span><span class="ident">i32</span><span class="op">></span>::<span class="ident">from</span>(<span class="ident">Owned</span>::<span class="ident">new</span>(<span class="number">1234</span>));</pre>
|
||
</div></div><h3 id='impl-From%3CBox%3CT%3E%3E' class='impl'><span class='in-band'><code>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><T>> for <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code><a href='#impl-From%3CBox%3CT%3E%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#530-534' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.from-1' class="method"><span id='from.v-1' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(b: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><T>) -> Self</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#531-533' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Performs the conversion.</p>
|
||
</div></div><h3 id='impl-From%3CT%3E' class='impl'><span class='in-band'><code>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code><a href='#impl-From%3CT%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#536-540' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.from-2' class="method"><span id='from.v-2' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -> Self</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#537-539' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Performs the conversion.</p>
|
||
</div></div><h3 id='impl-From%3CShared%3C%27g%2C%20T%3E%3E' class='impl'><span class='in-band'><code>impl<'g, T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="../crossbeam_epoch/struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><'g, T>> for <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code><a href='#impl-From%3CShared%3C%27g%2C%20T%3E%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#542-555' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.from-3' class="method"><span id='from.v-3' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(ptr: <a class="struct" href="../crossbeam_epoch/struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><'g, T>) -> Self</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#552-554' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Returns a new atomic pointer pointing to <code>ptr</code>.</p>
|
||
<h1 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::{<span class="ident">Atomic</span>, <span class="ident">Shared</span>};
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="op"><</span><span class="ident">i32</span><span class="op">></span>::<span class="ident">from</span>(<span class="ident">Shared</span>::<span class="op"><</span><span class="ident">i32</span><span class="op">></span>::<span class="ident">null</span>());</pre>
|
||
</div></div><h3 id='impl-From%3C*const%20T%3E' class='impl'><span class='in-band'><code>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*const T</a>> for <a class="struct" href="../crossbeam_epoch/struct.Atomic.html" title="struct crossbeam_epoch::Atomic">Atomic</a><T></code><a href='#impl-From%3C*const%20T%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#557-571' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.from-4' class="method"><span id='from.v-4' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(raw: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*const T</a>) -> Self</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/crossbeam_epoch/atomic.rs.html#568-570' title='goto source code'>[src]</a></span></h4>
|
||
<div class='docblock'><p>Returns a new atomic pointer pointing to <code>raw</code>.</p>
|
||
<h1 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ptr</span>;
|
||
<span class="kw">use</span> <span class="ident">crossbeam_epoch</span>::<span class="ident">Atomic</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">Atomic</span>::<span class="op"><</span><span class="ident">i32</span><span class="op">></span>::<span class="ident">from</span>(<span class="ident">ptr</span>::<span class="ident">null</span>::<span class="op"><</span><span class="ident">i32</span><span class="op">></span>());</pre>
|
||
</div></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><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 = "crossbeam_epoch";
|
||
</script>
|
||
<script src="../main.js"></script>
|
||
<script defer src="../search-index.js"></script>
|
||
</body>
|
||
</html> |