Lines Matching +full:send +full:- +full:empty
1 // SPDX-License-Identifier: GPL-2.0
7 //! from Rust; instead of making users have to use an additional Rust-reference count in the form of
29 /// Rust code, the recommendation is to use [`Arc`](crate::sync::Arc) to create reference-counted
37 /// Implementers must also ensure that all instances are reference-counted. (Otherwise they
58 /// An owned reference to an always-reference-counted object.
66 /// The pointer stored in `ptr` is non-null and valid for the lifetime of the [`ARef`] instance. In
73 // SAFETY: It is safe to send `ARef<T>` to another thread when the underlying `T` is `Sync` because
75 // `T` to be `Send` because any thread that has an `ARef<T>` may ultimately access `T` using a
77 unsafe impl<T: AlwaysRefCounted + Sync + Send> Send for ARef<T> {}
79 // SAFETY: It is safe to send `&ARef<T>` to another thread when the underlying `T` is `Sync`
81 // it needs `T` to be `Send` because any thread that has a `&ARef<T>` may clone it and get an
84 unsafe impl<T: AlwaysRefCounted + Sync + Send> Sync for ARef<T> {}
95 /// must not use the underlying object anymore -- it is only safe to do so via the newly
97 pub unsafe fn from_raw(ptr: NonNull<T>) -> Self {
117 /// struct Empty {}
120 /// unsafe impl AlwaysRefCounted for Empty {
125 /// let mut data = Empty {};
126 /// let ptr = NonNull::<Empty>::new(&mut data).unwrap();
128 /// let data_ref: ARef<Empty> = unsafe { ARef::from_raw(ptr) };
129 /// let raw_ptr: NonNull<Empty> = ARef::into_raw(data_ref);
133 pub fn into_raw(me: Self) -> NonNull<T> {
139 fn clone(&self) -> Self {
149 fn deref(&self) -> &Self::Target {
156 fn from(b: &T) -> Self {