53 lines
18 KiB
HTML
53 lines
18 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="Types that are pointed to by a single word."><title>Pointable in crossbeam_epoch - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="crossbeam_epoch" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">Pointable</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../crossbeam_epoch/index.html">crossbeam_<wbr>epoch</a><span class="version">0.9.18</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Pointable</a></h2><h3><a href="#required-associated-consts">Required Associated Constants</a></h3><ul class="block"><li><a href="#associatedconstant.ALIGN" title="ALIGN">ALIGN</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Init" title="Init">Init</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.deref" title="deref">deref</a></li><li><a href="#tymethod.deref_mut" title="deref_mut">deref_mut</a></li><li><a href="#tymethod.drop" title="drop">drop</a></li><li><a href="#tymethod.init" title="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" title="[MaybeUninit<T>]">[MaybeUninit<T>]</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate crossbeam_<wbr>epoch</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">crossbeam_epoch</a></div><h1>Trait <span class="trait">Pointable</span> <button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/crossbeam_epoch/atomic.rs.html#150-192">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Pointable {
|
|
type <a href="#associatedtype.Init" class="associatedtype">Init</a>;
|
|
|
|
const <a href="#associatedconstant.ALIGN" class="constant">ALIGN</a>: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>;
|
|
|
|
// Required methods
|
|
unsafe fn <a href="#tymethod.init" class="fn">init</a>(init: Self::<a class="associatedtype" href="trait.Pointable.html#associatedtype.Init" title="type crossbeam_epoch::Pointable::Init">Init</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>;
|
|
<span class="item-spacer"></span> unsafe fn <a href="#tymethod.deref" class="fn">deref</a><'a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -> &'a Self;
|
|
<span class="item-spacer"></span> unsafe fn <a href="#tymethod.deref_mut" class="fn">deref_mut</a><'a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -> &'a mut Self;
|
|
<span class="item-spacer"></span> unsafe fn <a href="#tymethod.drop" class="fn">drop</a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>);
|
|
}</code></pre><details class="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<T></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<T>]</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="struct crossbeam_epoch::Atomic"><code>Atomic</code></a>, <a href="struct.Owned.html" title="struct crossbeam_epoch::Owned"><code>Owned</code></a>, and <a href="struct.Shared.html" title="struct crossbeam_epoch::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::<[MaybeUninit<i32>]>::init(<span class="number">10</span>); <span class="comment">// allocating [i32; 10]</span></code></pre></div></div></details><h2 id="required-associated-consts" class="section-header">Required Associated Constants<a href="#required-associated-consts" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedconstant.ALIGN" class="method"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#152">Source</a><h4 class="code-header">const <a href="#associatedconstant.ALIGN" class="constant">ALIGN</a>: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>The alignment of pointer.</p>
|
|
</div></details></div><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Init" class="method"><a class="src 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-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.init" class="method"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#162">Source</a><h4 class="code-header">unsafe fn <a href="#tymethod.init" class="fn">init</a>(init: Self::<a class="associatedtype" href="trait.Pointable.html#associatedtype.Init" title="type crossbeam_epoch::Pointable::Init">Init</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Initializes a with the given initializer.</p>
|
|
<h5 id="safety"><a class="doc-anchor" href="#safety">§</a>Safety</h5>
|
|
<p>The result should be a multiple of <code>ALIGN</code>.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.deref" class="method"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#171">Source</a><h4 class="code-header">unsafe fn <a href="#tymethod.deref" class="fn">deref</a><'a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -> &'a Self</h4></section></summary><div class="docblock"><p>Dereferences the given pointer.</p>
|
|
<h5 id="safety-1"><a class="doc-anchor" href="#safety-1">§</a>Safety</h5>
|
|
<ul>
|
|
<li>The given <code>ptr</code> should have been initialized with <a href="trait.Pointable.html#tymethod.init" title="associated function crossbeam_epoch::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="associated function crossbeam_epoch::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="associated function crossbeam_epoch::Pointable::deref_mut"><code>Pointable::deref_mut</code></a> concurrently.</li>
|
|
</ul>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.deref_mut" class="method"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#181">Source</a><h4 class="code-header">unsafe fn <a href="#tymethod.deref_mut" class="fn">deref_mut</a><'a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -> &'a mut Self</h4></section></summary><div class="docblock"><p>Mutably dereferences the given pointer.</p>
|
|
<h5 id="safety-2"><a class="doc-anchor" href="#safety-2">§</a>Safety</h5>
|
|
<ul>
|
|
<li>The given <code>ptr</code> should have been initialized with <a href="trait.Pointable.html#tymethod.init" title="associated function crossbeam_epoch::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="associated function crossbeam_epoch::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="associated function crossbeam_epoch::Pointable::deref"><code>Pointable::deref</code></a> or <a href="trait.Pointable.html#tymethod.deref_mut" title="associated function crossbeam_epoch::Pointable::deref_mut"><code>Pointable::deref_mut</code></a>
|
|
concurrently.</li>
|
|
</ul>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.drop" class="method"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#191">Source</a><h4 class="code-header">unsafe fn <a href="#tymethod.drop" class="fn">drop</a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>)</h4></section></summary><div class="docblock"><p>Drops the object pointed to by the given pointer.</p>
|
|
<h5 id="safety-3"><a class="doc-anchor" href="#safety-3">§</a>Safety</h5>
|
|
<ul>
|
|
<li>The given <code>ptr</code> should have been initialized with <a href="trait.Pointable.html#tymethod.init" title="associated function crossbeam_epoch::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="associated function crossbeam_epoch::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="associated function crossbeam_epoch::Pointable::deref"><code>Pointable::deref</code></a> or <a href="trait.Pointable.html#tymethod.deref_mut" title="associated function crossbeam_epoch::Pointable::deref_mut"><code>Pointable::deref_mut</code></a>
|
|
concurrently.</li>
|
|
</ul>
|
|
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-Pointable-for-%5BMaybeUninit%3CT%3E%5D" class="impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#253-283">Source</a><a href="#impl-Pointable-for-%5BMaybeUninit%3CT%3E%5D" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="trait.Pointable.html" title="trait crossbeam_epoch::Pointable">Pointable</a> for [<a class="union" href="https://doc.rust-lang.org/1.93.1/core/mem/maybe_uninit/union.MaybeUninit.html" title="union core::mem::maybe_uninit::MaybeUninit">MaybeUninit</a><T>]</h3></section></summary><div class="impl-items"><section id="associatedconstant.ALIGN-1" class="associatedconstant trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#254">Source</a><a href="#associatedconstant.ALIGN-1" class="anchor">§</a><h4 class="code-header">const <a href="#associatedconstant.ALIGN" class="constant">ALIGN</a>: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a></h4></section><section id="associatedtype.Init-1" class="associatedtype trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#256">Source</a><a href="#associatedtype.Init-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Init" class="associatedtype">Init</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a></h4></section><section id="method.init" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#258-266">Source</a><a href="#method.init" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="#tymethod.init" class="fn">init</a>(len: Self::<a class="associatedtype" href="trait.Pointable.html#associatedtype.Init" title="type crossbeam_epoch::Pointable::Init">Init</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a></h4></section><section id="method.deref" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#268-271">Source</a><a href="#method.deref" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="#tymethod.deref" class="fn">deref</a><'a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -> &'a Self</h4></section><section id="method.deref_mut" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#273-276">Source</a><a href="#method.deref_mut" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="#tymethod.deref_mut" class="fn">deref_mut</a><'a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -> &'a mut Self</h4></section><section id="method.drop" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#278-282">Source</a><a href="#method.drop" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="#tymethod.drop" class="fn">drop</a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>)</h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-Pointable-for-T" class="impl"><a class="src 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<T> <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"><a class="src 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>: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a></h4></section><section id="associatedtype.Init-2" class="associatedtype trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#197">Source</a><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="../trait.impl/crossbeam_epoch/atomic/trait.Pointable.js" data-ignore-extern-crates="std" async></script></section></div></main></body></html> |