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