pub struct Ptr<'b, T> { /* private fields */ }
Expand description
Ptr
points to an instance.
Implementations§
source§impl<'b, T> Ptr<'b, T>
impl<'b, T> Ptr<'b, T>
sourcepub fn as_ref(&self) -> Option<&'b T>
pub fn as_ref(&self) -> Option<&'b T>
Tries to create a reference to the underlying instance.
Examples
use scc::ebr::{AtomicArc, Barrier};
use std::sync::atomic::Ordering::Relaxed;
let atomic_arc: AtomicArc<usize> = AtomicArc::new(21);
let barrier = Barrier::new();
let ptr = atomic_arc.load(Relaxed, &barrier);
assert_eq!(*ptr.as_ref().unwrap(), 21);
sourcepub fn as_raw(&self) -> *const T
pub fn as_raw(&self) -> *const T
Returns a raw pointer to the instance.
Examples
use scc::ebr::{Arc, Barrier};
use std::sync::atomic::Ordering::Relaxed;
let arc: Arc<usize> = Arc::new(29);
let barrier = Barrier::new();
let ptr = arc.ptr(&barrier);
assert_eq!(unsafe { *ptr.as_raw() }, 29);
sourcepub fn without_tag(self) -> Self
pub fn without_tag(self) -> Self
sourcepub fn get_arc(self) -> Option<Arc<T>>
pub fn get_arc(self) -> Option<Arc<T>>
Tries to convert itself into an Arc
.
Examples
use scc::ebr::{Arc, Barrier};
let arc: Arc<usize> = Arc::new(83);
let barrier = Barrier::new();
let ptr = arc.ptr(&barrier);
let converted_arc = ptr.get_arc().unwrap();
assert_eq!(*converted_arc, 83);
drop(arc);
drop(converted_arc);
assert!(ptr.get_arc().is_none());
Trait Implementations§
source§impl<'b, T> PartialEq<Ptr<'b, T>> for Ptr<'b, T>
impl<'b, T> PartialEq<Ptr<'b, T>> for Ptr<'b, T>
impl<'b, T> Copy for Ptr<'b, T>
impl<'b, T> Eq for Ptr<'b, T>
impl<'b, T: UnwindSafe> UnwindSafe for Ptr<'b, T>
Auto Trait Implementations§
impl<'b, T> !RefUnwindSafe for Ptr<'b, T>
impl<'b, T> !Send for Ptr<'b, T>
impl<'b, T> !Sync for Ptr<'b, T>
impl<'b, T> Unpin for Ptr<'b, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more