Lines Matching +full:reference +full:- +full:sync
1 // SPDX-License-Identifier: GPL-2.0
3 //! Atomic reference counting.
8 use crate::sync::atomic::Atomic;
11 /// Atomic reference counter.
25 /// The initial value should be non-saturated.
28 pub fn new(value: i32) -> Self { in new()
35 fn as_ptr(&self) -> *mut bindings::refcount_t { in as_ptr()
45 pub fn as_atomic(&self) -> &Atomic<i32> { in as_atomic()
47 // SAFETY: `refcount_t` is a transparent wrapper of `atomic_t`, which is an atomic 32-bit in as_atomic()
48 // integer that is layout-wise compatible with `Atomic<i32>`. All values are valid for in as_atomic()
63 /// represents a possible use-after-free condition.
65 /// Provides no memory ordering, it is assumed that caller already has a reference on the
97 /// A common pattern of using `Refcount` is to free memory when the reference count reaches
98 /// zero. This means that the reference to `Refcount` could become invalid after calling this
99 /// function. This is fine as long as the reference to `Refcount` is no longer used when this
101 /// <https://github.com/rust-lang/rust/issues/55005>.
104 pub fn dec_and_test(&self) -> bool { in dec_and_test()
110 // SAFETY: `refcount_t` is thread-safe.
113 // SAFETY: `refcount_t` is thread-safe.
114 unsafe impl Sync for Refcount {}