[−][src]Struct elysees::Arc
An atomically reference counted shared pointer
See the documentation for Arc
in the standard library.
Unlike the standard library Arc
, this Arc
holds a pointer to the T
instead of to the entire ArcInner
.
This makes the struct FFI-compatible, and allows a variety of pointer casts, e.g. &[Arc<T>]
to &[&T]
.
std::sync::Arc<T> elysees::Arc<T>
| |
v v
--------------------------------------
| RefCount | T (data) | [ArcInner<T>]
--------------------------------------
This means that this is a direct pointer to its contained data (and can be read from by both C/C++ and Rust)
This is very useful if you have an Arc-containing struct shared between Rust and C/C++,
and wish for C/C++ to be able to read the data behind the Arc
without incurring
an FFI call overhead. This also enables a variety of useful casts, which are provided as safe functions by
the library, e.g. &ArcByAddress
datastructures
Implementations
impl<T> Arc<T>
[src]
impl<T: ?Sized> Arc<T>
[src]
pub fn borrow_arc(&self) -> ArcBorrow<'_, T>
[src]
Borrow this Arc<T>
as an ArcBorrow<T>
pub fn leak(this: Arc<T>) -> ArcBorrow<'static, T>
[src]
Leak this Arc<T>
, getting an ArcBorrow<'static, T>
You can call the get
method on the returned ArcBorrow
to get an &'static T
.
Note that using this can (obviously) cause memory leaks!
pub fn into_raw(this: Self) -> *const T
[src]
Convert the Arc<T>
to a raw pointer, suitable for use across FFI
Note: This returns a pointer to the data T, which is offset in the allocation.
pub fn as_ptr(this: &Arc<T>) -> *const T
[src]
Get the raw pointer underlying this Arc<T>
pub unsafe fn from_raw(ptr: *const T) -> Arc<T>
[src]
Convert the Arc<T>
from a raw pointer obtained from into_raw()
Note: This raw pointer will be offset in the allocation and must be preceded by the atomic count.
Safety
This function must be called with a pointer obtained from into_raw()
, which
is then invalidated.
pub fn is_unique(&self) -> bool
[src]
Whether or not the Arc
is uniquely owned (is the refcount 1?).
pub fn try_unique(this: Self) -> Result<ArcBox<T>, Arc<T>>
[src]
Try to convert this Arc
to an ArcBox
if it is unique
pub fn count(this: &Arc<T>, ordering: LoadOrdering) -> usize
[src]
Get the reference count of this Arc
with a given ordering
pub fn ptr_eq(this: &Self, other: &Self) -> bool
[src]
Compare two Arc
s via pointer equality. Will only return
true if they come from the same allocation
impl<T: Clone> Arc<T>
[src]
pub fn make_mut(this: &mut Self) -> &mut T
[src]
Makes a mutable reference to the ArcHandle
, cloning if necessary
This is functionally equivalent to Arc::make_mut
from the standard library.
If this ArcHandle
is uniquely owned, make_mut()
will provide a mutable
reference to the contents. If not, make_mut()
will create a new ArcHandle
with a copy of the contents, update this
to point to it, and provide
a mutable reference to its contents.
This is useful for implementing copy-on-write schemes where you wish to
avoid copying things if your Arc
is not shared.
pub fn unique(this: Self) -> ArcBox<T>
[src]
Convert this Arc
to an ArcBox
, cloning the internal data if necessary for uniqueness
Trait Implementations
impl<S: ?Sized + SliceDst> AllocSliceDst<S> for Arc<S>
[src]
unsafe fn new_slice_dst<I>(len: usize, init: I) -> Self where
I: FnOnce(NonNull<S>),
[src]
I: FnOnce(NonNull<S>),
impl<T: ?Sized> AsRef<*const T> for Arc<T>
[src]
impl<T: ?Sized> AsRef<*mut T> for Arc<T>
[src]
impl<'a, T: ?Sized> AsRef<Arc<T>> for ArcBorrow<'a, T>
[src]
impl<T: ?Sized> AsRef<NonNull<T>> for Arc<T>
[src]
impl<T: ?Sized> AsRef<T> for Arc<T>
[src]
impl<'a, T: ?Sized> Borrow<Arc<T>> for ArcBorrow<'a, T>
[src]
impl<T: ?Sized> Borrow<T> for Arc<T>
[src]
impl<T: ?Sized> Clone for Arc<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: ?Sized> CloneStableDeref for Arc<T>
[src]
impl<T: ?Sized + Debug> Debug for Arc<T>
[src]
impl<T: Default> Default for Arc<T>
[src]
impl<T: ?Sized> Deref for Arc<T>
[src]
impl<T: ?Sized + Display> Display for Arc<T>
[src]
impl<T: ?Sized> Drop for Arc<T>
[src]
impl<T: ?Sized + Eq> Eq for Arc<T>
[src]
impl<T: ?Sized + Erasable> ErasablePtr for Arc<T>
[src]
impl<T> From<T> for Arc<T>
[src]
impl<T: ?Sized + Hash> Hash for Arc<T>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: ?Sized + Ord> Ord for Arc<T>
[src]
fn cmp(&self, other: &Arc<T>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: ?Sized + PartialEq> PartialEq<Arc<T>> for Arc<T>
[src]
impl<T: ?Sized + PartialOrd> PartialOrd<Arc<T>> for Arc<T>
[src]
fn partial_cmp(&self, other: &Arc<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &Arc<T>) -> bool
[src]
fn le(&self, other: &Arc<T>) -> bool
[src]
fn gt(&self, other: &Arc<T>) -> bool
[src]
fn ge(&self, other: &Arc<T>) -> bool
[src]
impl<T: ?Sized> Pointer for Arc<T>
[src]
impl<T: ?Sized + Sync + Send> Send for Arc<T>
[src]
impl<T: ?Sized> StableDeref for Arc<T>
[src]
impl<T: ?Sized + Sync + Send> Sync for Arc<T>
[src]
impl<S: ?Sized + SliceDst> TryAllocSliceDst<S> for Arc<S>
[src]
unsafe fn try_new_slice_dst<I, E>(len: usize, init: I) -> Result<Self, E> where
I: FnOnce(NonNull<S>) -> Result<(), E>,
[src]
I: FnOnce(NonNull<S>) -> Result<(), E>,
impl<T: ?Sized> UnionAlign for Arc<T> where
Arc<T>: ErasablePtr,
[src]
Arc<T>: ErasablePtr,
fn left<B: UnionAlign>(this: Self) -> Union2<Self, B>
[src]
fn right<A: UnionAlign>(this: Self) -> Union2<A, Self>
[src]
fn a<B: UnionAlign, C: UnionAlign, D: UnionAlign>(
this: Self
) -> Union4<Self, B, C, D>
[src]
this: Self
) -> Union4<Self, B, C, D>
fn b<A: UnionAlign, C: UnionAlign, D: UnionAlign>(
this: Self
) -> Union4<A, Self, C, D>
[src]
this: Self
) -> Union4<A, Self, C, D>
fn c<A: UnionAlign, B: UnionAlign, D: UnionAlign>(
this: Self
) -> Union4<A, B, Self, D>
[src]
this: Self
) -> Union4<A, B, Self, D>
fn d<A: UnionAlign, B: UnionAlign, C: UnionAlign>(
this: Self
) -> Union4<A, B, C, Self>
[src]
this: Self
) -> Union4<A, B, C, Self>
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for Arc<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T: ?Sized> Unpin for Arc<T> where
T: Unpin,
T: Unpin,
impl<T: ?Sized> UnwindSafe for Arc<T> where
T: RefUnwindSafe + UnwindSafe,
T: RefUnwindSafe + UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erasable for T
[src]
unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>
[src]
const ACK_1_1_0: bool
[src]
fn erase(this: NonNull<Self>) -> NonNull<Erased>
[src]
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,