blob: e060ceffa25e7991e68f752280f05cb3ffd34ab1 [file] [log] [blame]
<!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="Types that are pointed to by a single word."><meta name="keywords" content="rust, rustlang, rust-lang, Pointable"><title>Pointable in crossbeam_epoch - 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" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.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 trait"><!--[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="../crossbeam_epoch/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../crossbeam_epoch/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Pointable</a></h2><div class="sidebar-elems"><section><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Init">Init</a></li></ul><h3><a href="#required-associated-consts">Required Associated Constants</a></h3><ul class="block"><li><a href="#associatedconstant.ALIGN">ALIGN</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.deref">deref</a></li><li><a href="#tymethod.deref_mut">deref_mut</a></li><li><a href="#tymethod.drop">drop</a></li><li><a href="#tymethod.init">init</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-Pointable-for-%5BMaybeUninit%3CT%3E%5D">[MaybeUninit&lt;T&gt;]</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In crossbeam_epoch</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><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"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Trait <a href="index.html">crossbeam_epoch</a>::<wbr><a class="trait" href="#">Pointable</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></h1><span class="out-of-band"><a class="srclink" href="../src/crossbeam_epoch/atomic.rs.html#150-192">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="item-decl"><pre class="rust trait"><code>pub trait Pointable {
type <a href="#associatedtype.Init" class="associatedtype">Init</a>;
const <a href="#associatedconstant.ALIGN" class="constant">ALIGN</a>: usize;
unsafe fn <a href="#tymethod.init" class="fnname">init</a>(init: Self::<a class="associatedtype" href="trait.Pointable.html#associatedtype.Init" title="type crossbeam_epoch::Pointable::Init">Init</a>) -&gt; usize;
<span class="item-spacer"></span> unsafe fn <a href="#tymethod.deref" class="fnname">deref</a>&lt;'a&gt;(ptr: usize) -&gt; &amp;'a Self;
<span class="item-spacer"></span> unsafe fn <a href="#tymethod.deref_mut" class="fnname">deref_mut</a>&lt;'a&gt;(ptr: usize) -&gt; &amp;'a mut Self;
<span class="item-spacer"></span> unsafe fn <a href="#tymethod.drop" class="fnname">drop</a>(ptr: usize);
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Types that are pointed to by a single word.</p>
<p>In concurrent programming, it is necessary to represent an object within a word because atomic
operations (e.g., reads, writes, read-modify-writes) support only single words. This trait
qualifies such types that are pointed to by a single word.</p>
<p>The trait generalizes <code>Box&lt;T&gt;</code> for a sized type <code>T</code>. In a box, an object of type <code>T</code> is
allocated in heap and it is owned by a single-word pointer. This trait is also implemented for
<code>[MaybeUninit&lt;T&gt;]</code> by storing its size along with its elements and pointing to the pair of array
size and elements.</p>
<p>Pointers to <code>Pointable</code> types can be stored in <a href="struct.Atomic.html" title="Atomic"><code>Atomic</code></a>, <a href="struct.Owned.html" title="Owned"><code>Owned</code></a>, and <a href="struct.Shared.html" title="Shared"><code>Shared</code></a>. In
particular, Crossbeam supports dynamically sized slices as follows.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::mem::MaybeUninit;
<span class="kw">use </span>crossbeam_epoch::Owned;
<span class="kw">let </span>o = Owned::&lt;[MaybeUninit&lt;i32&gt;]&gt;::init(<span class="number">10</span>); <span class="comment">// allocating [i32; 10]</span></code></pre></div>
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="associatedtype.Init" class="method has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#155">source</a><h4 class="code-header">type <a href="#associatedtype.Init" class="associatedtype">Init</a></h4></section></summary><div class="docblock"><p>The type for initializers.</p>
</div></details></div><h2 id="required-associated-consts" class="small-section-header">Required Associated Constants<a href="#required-associated-consts" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="associatedconstant.ALIGN" class="method has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#152">source</a><h4 class="code-header">const <a href="#associatedconstant.ALIGN" class="constant">ALIGN</a>: usize</h4></section></summary><div class="docblock"><p>The alignment of pointer.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.init" class="method has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#162">source</a><h4 class="code-header">unsafe fn <a href="#tymethod.init" class="fnname">init</a>(init: Self::<a class="associatedtype" href="trait.Pointable.html#associatedtype.Init" title="type crossbeam_epoch::Pointable::Init">Init</a>) -&gt; usize</h4></section></summary><div class="docblock"><p>Initializes a with the given initializer.</p>
<h5 id="safety"><a href="#safety">Safety</a></h5>
<p>The result should be a multiple of <code>ALIGN</code>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.deref" class="method has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#171">source</a><h4 class="code-header">unsafe fn <a href="#tymethod.deref" class="fnname">deref</a>&lt;'a&gt;(ptr: usize) -&gt; &amp;'a Self</h4></section></summary><div class="docblock"><p>Dereferences the given pointer.</p>
<h5 id="safety-1"><a href="#safety-1">Safety</a></h5>
<ul>
<li>The given <code>ptr</code> should have been initialized with <a href="trait.Pointable.html#tymethod.init" title="Pointable::init"><code>Pointable::init</code></a>.</li>
<li><code>ptr</code> should not have yet been dropped by <a href="trait.Pointable.html#tymethod.drop" title="Pointable::drop"><code>Pointable::drop</code></a>.</li>
<li><code>ptr</code> should not be mutably dereferenced by <a href="trait.Pointable.html#tymethod.deref_mut" title="Pointable::deref_mut"><code>Pointable::deref_mut</code></a> concurrently.</li>
</ul>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.deref_mut" class="method has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#181">source</a><h4 class="code-header">unsafe fn <a href="#tymethod.deref_mut" class="fnname">deref_mut</a>&lt;'a&gt;(ptr: usize) -&gt; &amp;'a mut Self</h4></section></summary><div class="docblock"><p>Mutably dereferences the given pointer.</p>
<h5 id="safety-2"><a href="#safety-2">Safety</a></h5>
<ul>
<li>The given <code>ptr</code> should have been initialized with <a href="trait.Pointable.html#tymethod.init" title="Pointable::init"><code>Pointable::init</code></a>.</li>
<li><code>ptr</code> should not have yet been dropped by <a href="trait.Pointable.html#tymethod.drop" title="Pointable::drop"><code>Pointable::drop</code></a>.</li>
<li><code>ptr</code> should not be dereferenced by <a href="trait.Pointable.html#tymethod.deref" title="Pointable::deref"><code>Pointable::deref</code></a> or <a href="trait.Pointable.html#tymethod.deref_mut" title="Pointable::deref_mut"><code>Pointable::deref_mut</code></a>
concurrently.</li>
</ul>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.drop" class="method has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#191">source</a><h4 class="code-header">unsafe fn <a href="#tymethod.drop" class="fnname">drop</a>(ptr: usize)</h4></section></summary><div class="docblock"><p>Drops the object pointed to by the given pointer.</p>
<h5 id="safety-3"><a href="#safety-3">Safety</a></h5>
<ul>
<li>The given <code>ptr</code> should have been initialized with <a href="trait.Pointable.html#tymethod.init" title="Pointable::init"><code>Pointable::init</code></a>.</li>
<li><code>ptr</code> should not have yet been dropped by <a href="trait.Pointable.html#tymethod.drop" title="Pointable::drop"><code>Pointable::drop</code></a>.</li>
<li><code>ptr</code> should not be dereferenced by <a href="trait.Pointable.html#tymethod.deref" title="Pointable::deref"><code>Pointable::deref</code></a> or <a href="trait.Pointable.html#tymethod.deref_mut" title="Pointable::deref_mut"><code>Pointable::deref_mut</code></a>
concurrently.</li>
</ul>
</div></details></div><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Pointable-for-%5BMaybeUninit%3CT%3E%5D" class="impl has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#246-280">source</a><a href="#impl-Pointable-for-%5BMaybeUninit%3CT%3E%5D" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="trait.Pointable.html" title="trait crossbeam_epoch::Pointable">Pointable</a> for [MaybeUninit&lt;T&gt;]</h3></section></summary><div class="impl-items"><section id="associatedconstant.ALIGN-1" class="associatedconstant trait-impl has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#247">source</a><a href="#associatedconstant.ALIGN-1" class="anchor"></a><h4 class="code-header">const <a href="#associatedconstant.ALIGN" class="constant">ALIGN</a>: usize = _</h4></section><section id="associatedtype.Init-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Init-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Init" class="associatedtype">Init</a> = usize</h4></section><section id="method.init" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#251-261">source</a><a href="#method.init" class="anchor"></a><h4 class="code-header">unsafe fn <a href="#tymethod.init" class="fnname">init</a>(len: Self::<a class="associatedtype" href="trait.Pointable.html#associatedtype.Init" title="type crossbeam_epoch::Pointable::Init">Init</a>) -&gt; usize</h4></section><section id="method.deref" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#263-266">source</a><a href="#method.deref" class="anchor"></a><h4 class="code-header">unsafe fn <a href="#tymethod.deref" class="fnname">deref</a>&lt;'a&gt;(ptr: usize) -&gt; &amp;'a Self</h4></section><section id="method.deref_mut" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#268-271">source</a><a href="#method.deref_mut" class="anchor"></a><h4 class="code-header">unsafe fn <a href="#tymethod.deref_mut" class="fnname">deref_mut</a>&lt;'a&gt;(ptr: usize) -&gt; &amp;'a mut Self</h4></section><section id="method.drop" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#273-279">source</a><a href="#method.drop" class="anchor"></a><h4 class="code-header">unsafe fn <a href="#tymethod.drop" class="fnname">drop</a>(ptr: usize)</h4></section></div></details><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Pointable-for-T" class="impl has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#194-214">source</a><a href="#impl-Pointable-for-T" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="trait.Pointable.html" title="trait crossbeam_epoch::Pointable">Pointable</a> for T</h3></section></summary><div class="impl-items"><section id="associatedconstant.ALIGN-2" class="associatedconstant trait-impl has-srclink"><a class="srclink rightside" href="../src/crossbeam_epoch/atomic.rs.html#195">source</a><a href="#associatedconstant.ALIGN-2" class="anchor"></a><h4 class="code-header">const <a href="#associatedconstant.ALIGN" class="constant">ALIGN</a>: usize = _</h4></section><section id="associatedtype.Init-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Init-2" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Init" class="associatedtype">Init</a> = T</h4></section></div></details></div><script src="../implementors/crossbeam_epoch/atomic/trait.Pointable.js" data-ignore-extern-crates="core" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="crossbeam_epoch" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>