Lines Matching refs:refcount
62 /// // Get a new pointer to `obj` and increment the refcount.
68 /// // Destroy `obj` and decrement its refcount.
75 /// // The refcount drops to zero when `cloned` goes out of scope, and the memory is freed.
146 refcount: Opaque<bindings::refcount_t>,
208 // INVARIANT: The refcount is initialised to a non-zero value.
211 refcount: Opaque::new(unsafe { bindings::REFCOUNT_INIT(1) }),
241 /// The raw pointer has ownership of the refcount that this Arc object owned.
295 /// // The above conversion should succeed since refcount of `arc` is 1.
311 /// // The above conversion should fail since refcount of `arc` is >1.
317 // We will manually manage the refcount in this method, so we disable the destructor.
319 // SAFETY: We own a refcount, so the pointer is still valid.
320 let refcount = unsafe { me.ptr.as_ref() }.refcount.get();
322 // If the refcount reaches a non-zero value, then we have destroyed this `Arc` and will
323 // return without further touching the `Arc`. If the refcount reaches zero, then there are
326 // SAFETY: We own a refcount, so the pointer is not dangling.
327 let is_zero = unsafe { bindings::refcount_dec_and_test(refcount) };
330 // accesses to the refcount.
331 unsafe { core::ptr::write(refcount, bindings::REFCOUNT_INIT(1)) };
333 // INVARIANT: We own the only refcount to this arc, so we may create a `UniqueArc`. We
401 let refcount = unsafe { self.ptr.as_ref() }.refcount.get();
403 // INVARIANT: C `refcount_inc` saturates the refcount, so it cannot overflow to zero.
405 // safe to increment the refcount.
406 unsafe { bindings::refcount_inc(refcount) };
408 // SAFETY: We just incremented the refcount. This increment is now owned by the new `Arc`.
416 // touch `refcount` after it's decremented to a non-zero value because another thread/CPU
419 let refcount = unsafe { self.ptr.as_ref() }.refcount.get();
421 // INVARIANT: If the refcount reaches zero, there are no other instances of `Arc`, and
423 // SAFETY: Also by the type invariant, we are allowed to decrement the refcount.
424 let is_zero = unsafe { bindings::refcount_dec_and_test(refcount) };
449 /// For cases when one doesn't ever need to increment the refcount on the allocation, it is simpler
452 /// However, when one may need to increment the refcount, it is preferable to use an `ArcBorrow<T>`
455 /// indirection while still allowing one to increment the refcount and getting an [`Arc<T>`] when/if
565 // SAFETY: The existence of `b` guarantees that the refcount is non-zero. `ManuallyDrop`
584 /// A refcounted object that is known to have a refcount of 1.
666 // INVARIANT: The newly-created object has a refcount of 1.
673 // INVARIANT: The refcount is initialised to a non-zero value.
677 refcount: Opaque::new(unsafe { bindings::REFCOUNT_INIT(1) }),
683 // INVARIANT: The newly-created object has a refcount of 1.