Lines Matching full:arc

5 //! A wrapper around `Arc` for linked lists.
9 use crate::sync::{Arc, ArcBorrow, UniqueArc};
58 /// Attempts to convert an `Arc<Self>` into an `ListArc<Self>`. Returns `true` if the
131 /// A wrapper around [`Arc`] that's guaranteed unique for the given id.
142 /// creation of new `ListArc` references from an [`Arc`] reference. Whatever strategy is used, the
152 /// While this `ListArc` is unique for the given id, there still might exist normal `Arc`
167 arc: Arc<T>, field
181 // what we do for `Arc`.
222 let arc = Arc::from(unique); in from() localVariable
223 // SAFETY: We just called `on_create_list_arc_from_unique` on an arc without a `ListArc`, in from()
225 unsafe { Self::transmute_from_arc(arc) } in from()
261 let arc1 = Arc::from(unique); in pair_from_pin_unique()
262 let arc2 = Arc::clone(&arc1); in pair_from_pin_unique()
264 // SAFETY: We just called `on_create_list_arc_from_unique` on an arc without a `ListArc` in pair_from_pin_unique()
277 pub fn try_from_arc(arc: Arc<T>) -> Result<Self, Arc<T>> in try_from_arc()
281 if arc.try_new_list_arc() { in try_from_arc()
284 Ok(unsafe { Self::transmute_from_arc(arc) }) in try_from_arc()
286 Err(arc) in try_from_arc()
293 pub fn try_from_arc_borrow(arc: ArcBorrow<'_, T>) -> Option<Self> in try_from_arc_borrow()
297 if arc.try_new_list_arc() { in try_from_arc_borrow()
300 Some(unsafe { Self::transmute_from_arc(Arc::from(arc)) }) in try_from_arc_borrow()
308 /// If it's not possible to create a new `ListArc`, then the `Arc` is dropped. This will never
310 pub fn try_from_arc_or_drop(arc: Arc<T>) -> Option<Self> in try_from_arc_or_drop()
314 match Self::try_from_arc(arc) { in try_from_arc_or_drop()
316 Err(arc) => Arc::into_unique_or_drop(arc).map(Self::from), in try_from_arc_or_drop()
320 /// Transmutes an [`Arc`] into a `ListArc` without updating the tracking inside `T`.
327 unsafe fn transmute_from_arc(arc: Arc<T>) -> Self { in transmute_from_arc()
329 Self { arc } in transmute_from_arc()
332 /// Transmutes a `ListArc` into an [`Arc`] without updating the tracking inside `T`.
337 fn transmute_to_arc(self) -> Arc<T> { in transmute_to_arc()
346 /// The returned pointer is indistinguishable from pointers returned by [`Arc::into_raw`]. The
350 Arc::into_raw(Self::transmute_to_arc(self)) in into_raw()
357 /// * `ptr` must satisfy the safety requirements of [`Arc::from_raw`].
362 // SAFETY: The pointer satisfies the safety requirements for `Arc::from_raw`. in from_raw()
363 let arc = unsafe { Arc::from_raw(ptr) }; in from_raw() localVariable
366 unsafe { Self::transmute_from_arc(arc) } in from_raw()
369 /// Converts the `ListArc` into an [`Arc`].
371 pub fn into_arc(self) -> Arc<T> { in into_arc()
372 let arc = Self::transmute_to_arc(self); in into_arc() localVariable
374 unsafe { T::on_drop_list_arc(&arc) }; in into_arc()
375 arc in into_arc()
378 /// Clone a `ListArc` into an [`Arc`].
380 pub fn clone_arc(&self) -> Arc<T> { in clone_arc()
381 self.arc.clone() in clone_arc()
384 /// Returns a reference to an [`Arc`] from the given [`ListArc`].
386 /// This is useful when the argument of a function call is an [`&Arc`] (e.g., in a method
389 /// [`&Arc`]: Arc
391 pub fn as_arc(&self) -> &Arc<T> { in as_arc()
392 &self.arc in as_arc()
398 /// receiver), but we have an [`Arc`] instead. Getting an [`ArcBorrow`] is free when optimised.
401 self.arc.as_arc_borrow() in as_arc_borrow()
407 Arc::ptr_eq(&this.arc, &other.arc) in ptr_eq()
419 self.arc.deref() in deref()
431 unsafe { T::on_drop_list_arc(&self.arc) }; in drop()
435 impl<T, const ID: u64> AsRef<Arc<T>> for ListArc<T, ID>
440 fn as_ref(&self) -> &Arc<T> { in as_ref()
480 // INVARIANT: Pin-init initializers can't be used on an existing `Arc`, so this value will in new()
481 // not be constructed in an `Arc` that already has a `ListArc`. in new()