Coverage Report

Created: 2021-01-22 16:54

crossbeam-epoch/src/atomic.rs
Line
Count
Source (jump to first uncovered line)
1
use core::borrow::{Borrow, BorrowMut};
2
use core::cmp;
3
use core::fmt;
4
use core::marker::PhantomData;
5
use core::mem::{self, MaybeUninit};
6
use core::ops::{Deref, DerefMut};
7
use core::slice;
8
use core::sync::atomic::Ordering;
9
10
use crate::alloc::alloc;
11
use crate::alloc::boxed::Box;
12
use crate::guard::Guard;
13
use crate::primitive::sync::atomic::AtomicUsize;
14
use crossbeam_utils::atomic::AtomicConsume;
15
16
/// Given ordering for the success case in a compare-exchange operation, returns the strongest
17
/// appropriate ordering for the failure case.
18
#[inline]
19
0
fn strongest_failure_ordering(ord: Ordering) -> Ordering {
20
0
    use self::Ordering::*;
21
0
    match ord {
22
0
        Relaxed | Release => Relaxed,
23
0
        Acquire | AcqRel => Acquire,
24
0
        _ => SeqCst,
25
    }
26
0
}
27
28
/// The error returned on failed compare-and-set operation.
29
// TODO: remove in the next major version.
30
#[deprecated(note = "Use `CompareExchangeError` instead")]
31
pub type CompareAndSetError<'g, T, P> = CompareExchangeError<'g, T, P>;
32
33
/// The error returned on failed compare-and-swap operation.
34
pub struct CompareExchangeError<'g, T: ?Sized + Pointable, P: Pointer<T>> {
35
    /// The value in the atomic pointer at the time of the failed operation.
36
    pub current: Shared<'g, T>,
37
38
    /// The new value, which the operation failed to store.
39
    pub new: P,
40
}
41
42
impl<T, P: Pointer<T> + fmt::Debug> fmt::Debug for CompareExchangeError<'_, T, P> {
43
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44
0
        f.debug_struct("CompareExchangeError")
45
0
            .field("current", &self.current)
46
0
            .field("new", &self.new)
47
0
            .finish()
48
0
    }
49
}
50
51
/// Memory orderings for compare-and-set operations.
52
///
53
/// A compare-and-set operation can have different memory orderings depending on whether it
54
/// succeeds or fails. This trait generalizes different ways of specifying memory orderings.
55
///
56
/// The two ways of specifying orderings for compare-and-set are:
57
///
58
/// 1. Just one `Ordering` for the success case. In case of failure, the strongest appropriate
59
///    ordering is chosen.
60
/// 2. A pair of `Ordering`s. The first one is for the success case, while the second one is
61
///    for the failure case.
62
// TODO: remove in the next major version.
63
#[deprecated(
64
    note = "`compare_and_set` and `compare_and_set_weak` that use this trait are deprecated, \
65
            use `compare_exchange` or `compare_exchange_weak instead`"
66
)]
67
pub trait CompareAndSetOrdering {
68
    /// The ordering of the operation when it succeeds.
69
    fn success(&self) -> Ordering;
70
71
    /// The ordering of the operation when it fails.
72
    ///
73
    /// The failure ordering can't be `Release` or `AcqRel` and must be equivalent or weaker than
74
    /// the success ordering.
75
    fn failure(&self) -> Ordering;
76
}
77
78
#[allow(deprecated)]
79
impl CompareAndSetOrdering for Ordering {
80
    #[inline]
81
0
    fn success(&self) -> Ordering {
82
0
        *self
83
0
    }
84
85
    #[inline]
86
0
    fn failure(&self) -> Ordering {
87
0
        strongest_failure_ordering(*self)
88
0
    }
89
}
90
91
#[allow(deprecated)]
92
impl CompareAndSetOrdering for (Ordering, Ordering) {
93
    #[inline]
94
0
    fn success(&self) -> Ordering {
95
0
        self.0
96
0
    }
97
98
    #[inline]
99
0
    fn failure(&self) -> Ordering {
100
0
        self.1
101
0
    }
102
}
103
104
/// Returns a bitmask containing the unused least significant bits of an aligned pointer to `T`.
105
#[inline]
106
88.7M
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
88.7M
    (1 << T::ALIGN.trailing_zeros()) - 1
108
88.7M
}
crossbeam_epoch::atomic::low_bits::<crossbeam_skiplist::base::Node<i32, i32>>
Line
Count
Source
106
2.50k
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
2.50k
    (1 << T::ALIGN.trailing_zeros()) - 1
108
2.50k
}
crossbeam_epoch::atomic::low_bits::<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>
Line
Count
Source
106
40.9k
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
40.9k
    (1 << T::ALIGN.trailing_zeros()) - 1
108
40.9k
}
crossbeam_epoch::atomic::low_bits::<crossbeam_epoch::sync::list::Entry>
Line
Count
Source
106
345k
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
345k
    (1 << T::ALIGN.trailing_zeros()) - 1
108
345k
}
crossbeam_epoch::atomic::low_bits::<crossbeam_epoch::internal::Local>
Line
Count
Source
106
963
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
963
    (1 << T::ALIGN.trailing_zeros()) - 1
108
963
}
crossbeam_epoch::atomic::low_bits::<crossbeam_deque::deque::Buffer<usize>>
Line
Count
Source
106
44
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
44
    (1 << T::ALIGN.trailing_zeros()) - 1
108
44
}
crossbeam_epoch::atomic::low_bits::<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>
Line
Count
Source
106
32
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
32
    (1 << T::ALIGN.trailing_zeros()) - 1
108
32
}
crossbeam_epoch::atomic::low_bits::<crossbeam_skiplist::base::Node<i32, ()>>
Line
Count
Source
106
43
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
43
    (1 << T::ALIGN.trailing_zeros()) - 1
108
43
}
crossbeam_epoch::atomic::low_bits::<crossbeam_skiplist::base::Node<i32, i32>>
Line
Count
Source
106
5.94k
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
5.94k
    (1 << T::ALIGN.trailing_zeros()) - 1
108
5.94k
}
crossbeam_epoch::atomic::low_bits::<crossbeam_skiplist::base::Node<alloc::string::String, alloc::boxed::Box<i32>>>
Line
Count
Source
106
2
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
2
    (1 << T::ALIGN.trailing_zeros()) - 1
108
2
}
crossbeam_epoch::atomic::low_bits::<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>
Line
Count
Source
106
157
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
157
    (1 << T::ALIGN.trailing_zeros()) - 1
108
157
}
crossbeam_epoch::atomic::low_bits::<crossbeam_deque::deque::Buffer<i32>>
Line
Count
Source
106
4
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
4
    (1 << T::ALIGN.trailing_zeros()) - 1
108
4
}
crossbeam_epoch::atomic::low_bits::<crossbeam_deque::deque::Buffer<i32>>
Line
Count
Source
106
20
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
20
    (1 << T::ALIGN.trailing_zeros()) - 1
108
20
}
crossbeam_epoch::atomic::low_bits::<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>
Line
Count
Source
106
89.0k
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
89.0k
    (1 << T::ALIGN.trailing_zeros()) - 1
108
89.0k
}
crossbeam_epoch::atomic::low_bits::<crossbeam_deque::deque::Buffer<usize>>
Line
Count
Source
106
1.05M
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
1.05M
    (1 << T::ALIGN.trailing_zeros()) - 1
108
1.05M
}
crossbeam_epoch::atomic::low_bits::<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>
Line
Count
Source
106
100k
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
100k
    (1 << T::ALIGN.trailing_zeros()) - 1
108
100k
}
crossbeam_epoch::atomic::low_bits::<crossbeam_deque::deque::Buffer<i32>>
Line
Count
Source
106
180
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
180
    (1 << T::ALIGN.trailing_zeros()) - 1
108
180
}
crossbeam_epoch::atomic::low_bits::<crossbeam_deque::deque::Buffer<i32>>
Line
Count
Source
106
22
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
22
    (1 << T::ALIGN.trailing_zeros()) - 1
108
22
}
crossbeam_epoch::atomic::low_bits::<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>
Line
Count
Source
106
99.6k
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
99.6k
    (1 << T::ALIGN.trailing_zeros()) - 1
108
99.6k
}
crossbeam_epoch::atomic::low_bits::<crossbeam_deque::deque::Buffer<usize>>
Line
Count
Source
106
428k
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
428k
    (1 << T::ALIGN.trailing_zeros()) - 1
108
428k
}
crossbeam_epoch::atomic::low_bits::<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>
Line
Count
Source
106
166k
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
166k
    (1 << T::ALIGN.trailing_zeros()) - 1
108
166k
}
crossbeam_epoch::atomic::low_bits::<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>
Line
Count
Source
106
14.2M
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
14.2M
    (1 << T::ALIGN.trailing_zeros()) - 1
108
14.2M
}
crossbeam_epoch::atomic::low_bits::<crossbeam_epoch::collector::tests::count_drops::Elem>
Line
Count
Source
106
400k
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
400k
    (1 << T::ALIGN.trailing_zeros()) - 1
108
400k
}
crossbeam_epoch::atomic::low_bits::<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>
Line
Count
Source
106
7.65M
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
7.65M
    (1 << T::ALIGN.trailing_zeros()) - 1
108
7.65M
}
crossbeam_epoch::atomic::low_bits::<crossbeam_epoch::sync::list::Entry>
Line
Count
Source
106
29.3M
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
29.3M
    (1 << T::ALIGN.trailing_zeros()) - 1
108
29.3M
}
crossbeam_epoch::atomic::low_bits::<crossbeam_epoch::collector::tests::stress::Elem>
Line
Count
Source
106
2.42M
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
2.42M
    (1 << T::ALIGN.trailing_zeros()) - 1
108
2.42M
}
crossbeam_epoch::atomic::low_bits::<i8>
Line
Count
Source
106
2
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
2
    (1 << T::ALIGN.trailing_zeros()) - 1
108
2
}
crossbeam_epoch::atomic::low_bits::<i32>
Line
Count
Source
106
747k
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
747k
    (1 << T::ALIGN.trailing_zeros()) - 1
108
747k
}
crossbeam_epoch::atomic::low_bits::<i64>
Line
Count
Source
106
2
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
2
    (1 << T::ALIGN.trailing_zeros()) - 1
108
2
}
crossbeam_epoch::atomic::low_bits::<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>>
Line
Count
Source
106
4
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
4
    (1 << T::ALIGN.trailing_zeros()) - 1
108
4
}
crossbeam_epoch::atomic::low_bits::<crossbeam_epoch::internal::Local>
Line
Count
Source
106
607
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
607
    (1 << T::ALIGN.trailing_zeros()) - 1
108
607
}
crossbeam_epoch::atomic::low_bits::<crossbeam_epoch::sync::queue::Node<i64>>
Line
Count
Source
106
31.5M
fn low_bits<T: ?Sized + Pointable>() -> usize {
107
31.5M
    (1 << T::ALIGN.trailing_zeros()) - 1
108
31.5M
}
109
110
/// Panics if the pointer is not properly unaligned.
111
#[inline]
112
16.6k
fn ensure_aligned<T: ?Sized + Pointable>(raw: usize) {
113
16.6k
    assert_eq!(raw & low_bits::<T>(), 0, 
"unaligned pointer"0
);
114
16.6k
}
crossbeam_epoch::atomic::ensure_aligned::<crossbeam_skiplist::base::Node<i32, i32>>
Line
Count
Source
112
25
fn ensure_aligned<T: ?Sized + Pointable>(raw: usize) {
113
25
    assert_eq!(raw & low_bits::<T>(), 0, 
"unaligned pointer"0
);
114
25
}
crossbeam_epoch::atomic::ensure_aligned::<crossbeam_epoch::sync::list::Entry>
Line
Count
Source
112
146
fn ensure_aligned<T: ?Sized + Pointable>(raw: usize) {
113
146
    assert_eq!(raw & low_bits::<T>(), 0, 
"unaligned pointer"0
);
114
146
}
crossbeam_epoch::atomic::ensure_aligned::<crossbeam_epoch::internal::Local>
Line
Count
Source
112
99
fn ensure_aligned<T: ?Sized + Pointable>(raw: usize) {
113
99
    assert_eq!(raw & low_bits::<T>(), 0, 
"unaligned pointer"0
);
114
99
}
crossbeam_epoch::atomic::ensure_aligned::<crossbeam_skiplist::base::Node<i32, ()>>
Line
Count
Source
112
3
fn ensure_aligned<T: ?Sized + Pointable>(raw: usize) {
113
3
    assert_eq!(raw & low_bits::<T>(), 0, 
"unaligned pointer"0
);
114
3
}
crossbeam_epoch::atomic::ensure_aligned::<crossbeam_skiplist::base::Node<i32, i32>>
Line
Count
Source
112
170
fn ensure_aligned<T: ?Sized + Pointable>(raw: usize) {
113
170
    assert_eq!(raw & low_bits::<T>(), 0, 
"unaligned pointer"0
);
114
170
}
crossbeam_epoch::atomic::ensure_aligned::<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>
Line
Count
Source
112
8
fn ensure_aligned<T: ?Sized + Pointable>(raw: usize) {
113
8
    assert_eq!(raw & low_bits::<T>(), 0, 
"unaligned pointer"0
);
114
8
}
crossbeam_epoch::atomic::ensure_aligned::<crossbeam_epoch::internal::Local>
Line
Count
Source
112
67
fn ensure_aligned<T: ?Sized + Pointable>(raw: usize) {
113
67
    assert_eq!(raw & low_bits::<T>(), 0, 
"unaligned pointer"0
);
114
67
}
crossbeam_epoch::atomic::ensure_aligned::<crossbeam_epoch::sync::list::Entry>
Line
Count
Source
112
16.1k
fn ensure_aligned<T: ?Sized + Pointable>(raw: usize) {
113
16.1k
    assert_eq!(raw & low_bits::<T>(), 0, 
"unaligned pointer"0
);
114
16.1k
}
115
116
/// Given a tagged pointer `data`, returns the same pointer, but tagged with `tag`.
117
///
118
/// `tag` is truncated to fit into the unused bits of the pointer to `T`.
119
#[inline]
120
8.38k
fn compose_tag<T: ?Sized + Pointable>(data: usize, tag: usize) -> usize {
121
8.38k
    (data & !low_bits::<T>()) | (tag & low_bits::<T>())
122
8.38k
}
crossbeam_epoch::atomic::compose_tag::<crossbeam_skiplist::base::Node<i32, i32>>
Line
Count
Source
120
5
fn compose_tag<T: ?Sized + Pointable>(data: usize, tag: usize) -> usize {
121
5
    (data & !low_bits::<T>()) | (tag & low_bits::<T>())
122
5
}
crossbeam_epoch::atomic::compose_tag::<crossbeam_epoch::sync::list::Entry>
Line
Count
Source
120
99
fn compose_tag<T: ?Sized + Pointable>(data: usize, tag: usize) -> usize {
121
99
    (data & !low_bits::<T>()) | (tag & low_bits::<T>())
122
99
}
crossbeam_epoch::atomic::compose_tag::<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>
Line
Count
Source
120
1
fn compose_tag<T: ?Sized + Pointable>(data: usize, tag: usize) -> usize {
121
1
    (data & !low_bits::<T>()) | (tag & low_bits::<T>())
122
1
}
crossbeam_epoch::atomic::compose_tag::<crossbeam_skiplist::base::Node<i32, i32>>
Line
Count
Source
120
64
fn compose_tag<T: ?Sized + Pointable>(data: usize, tag: usize) -> usize {
121
64
    (data & !low_bits::<T>()) | (tag & low_bits::<T>())
122
64
}
crossbeam_epoch::atomic::compose_tag::<crossbeam_epoch::sync::list::Entry>
Line
Count
Source
120
8.21k
fn compose_tag<T: ?Sized + Pointable>(data: usize, tag: usize) -> usize {
121
8.21k
    (data & !low_bits::<T>()) | (tag & low_bits::<T>())
122
8.21k
}
crossbeam_epoch::atomic::compose_tag::<i8>
Line
Count
Source
120
1
fn compose_tag<T: ?Sized + Pointable>(data: usize, tag: usize) -> usize {
121
1
    (data & !low_bits::<T>()) | (tag & low_bits::<T>())
122
1
}
crossbeam_epoch::atomic::compose_tag::<i64>
Line
Count
Source
120
1
fn compose_tag<T: ?Sized + Pointable>(data: usize, tag: usize) -> usize {
121
1
    (data & !low_bits::<T>()) | (tag & low_bits::<T>())
122
1
}
123
124
/// Decomposes a tagged pointer `data` into the pointer and the tag.
125
#[inline]
126
47.8M
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
47.8M
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
47.8M
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_skiplist::base::Node<i32, i32>>
Line
Count
Source
126
1.23k
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
1.23k
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
1.23k
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_epoch::sync::list::Entry>
Line
Count
Source
126
173k
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
173k
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
173k
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_epoch::internal::Local>
Line
Count
Source
126
432
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
432
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
432
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>
Line
Count
Source
126
20.4k
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
20.4k
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
20.4k
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>
Line
Count
Source
126
16
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
16
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
16
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_deque::deque::Buffer<usize>>
Line
Count
Source
126
22
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
22
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
22
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_skiplist::base::Node<i32, ()>>
Line
Count
Source
126
20
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
20
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
20
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_skiplist::base::Node<alloc::string::String, alloc::boxed::Box<i32>>>
Line
Count
Source
126
1
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
1
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
1
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>
Line
Count
Source
126
73
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
73
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
73
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_skiplist::base::Node<i32, i32>>
Line
Count
Source
126
3.06k
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
3.06k
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
3.06k
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_deque::deque::Buffer<i32>>
Line
Count
Source
126
2
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
2
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
2
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_deque::deque::Buffer<i32>>
Line
Count
Source
126
10
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
10
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
10
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_deque::deque::Buffer<usize>>
Line
Count
Source
126
580k
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
580k
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
580k
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>
Line
Count
Source
126
50.1k
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
50.1k
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
50.1k
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>
Line
Count
Source
126
45.2k
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
45.2k
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
45.2k
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_deque::deque::Buffer<i32>>
Line
Count
Source
126
90
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
90
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
90
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_deque::deque::Buffer<i32>>
Line
Count
Source
126
11
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
11
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
11
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>
Line
Count
Source
126
84.6k
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
84.6k
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
84.6k
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_deque::deque::Buffer<usize>>
Line
Count
Source
126
220k
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
220k
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
220k
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>
Line
Count
Source
126
49.8k
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
49.8k
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
49.8k
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>
Line
Count
Source
126
3.86M
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
3.86M
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
3.86M
}
crossbeam_epoch::atomic::decompose_tag::<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>>
Line
Count
Source
126
2
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
2
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
2
}
crossbeam_epoch::atomic::decompose_tag::<i32>
Line
Count
Source
126
376k
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
376k
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
376k
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_epoch::sync::list::Entry>
Line
Count
Source
126
16.1M
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
16.1M
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
16.1M
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_epoch::collector::tests::stress::Elem>
Line
Count
Source
126
1.20M
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
1.20M
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
1.20M
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_epoch::collector::tests::count_drops::Elem>
Line
Count
Source
126
200k
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
200k
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
200k
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>
Line
Count
Source
126
7.28M
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
7.28M
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
7.28M
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_epoch::sync::queue::Node<i64>>
Line
Count
Source
126
17.5M
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
17.5M
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
17.5M
}
crossbeam_epoch::atomic::decompose_tag::<crossbeam_epoch::internal::Local>
Line
Count
Source
126
270
fn decompose_tag<T: ?Sized + Pointable>(data: usize) -> (usize, usize) {
127
270
    (data & !low_bits::<T>(), data & low_bits::<T>())
128
270
}
129
130
/// Types that are pointed to by a single word.
131
///
132
/// In concurrent programming, it is necessary to represent an object within a word because atomic
133
/// operations (e.g., reads, writes, read-modify-writes) support only single words.  This trait
134
/// qualifies such types that are pointed to by a single word.
135
///
136
/// The trait generalizes `Box<T>` for a sized type `T`.  In a box, an object of type `T` is
137
/// allocated in heap and it is owned by a single-word pointer.  This trait is also implemented for
138
/// `[MaybeUninit<T>]` by storing its size along with its elements and pointing to the pair of array
139
/// size and elements.
140
///
141
/// Pointers to `Pointable` types can be stored in [`Atomic`], [`Owned`], and [`Shared`].  In
142
/// particular, Crossbeam supports dynamically sized slices as follows.
143
///
144
/// ```
145
/// use std::mem::MaybeUninit;
146
/// use crossbeam_epoch::Owned;
147
///
148
/// let o = Owned::<[MaybeUninit<i32>]>::init(10); // allocating [i32; 10]
149
/// ```
150
pub trait Pointable {
151
    /// The alignment of pointer.
152
    const ALIGN: usize;
153
154
    /// The type for initializers.
155
    type Init;
156
157
    /// Initializes a with the given initializer.
158
    ///
159
    /// # Safety
160
    ///
161
    /// The result should be a multiple of `ALIGN`.
162
    unsafe fn init(init: Self::Init) -> usize;
163
164
    /// Dereferences the given pointer.
165
    ///
166
    /// # Safety
167
    ///
168
    /// - The given `ptr` should have been initialized with [`Pointable::init`].
169
    /// - `ptr` should not have yet been dropped by [`Pointable::drop`].
170
    /// - `ptr` should not be mutably dereferenced by [`Pointable::deref_mut`] concurrently.
171
    unsafe fn deref<'a>(ptr: usize) -> &'a Self;
172
173
    /// Mutably dereferences the given pointer.
174
    ///
175
    /// # Safety
176
    ///
177
    /// - The given `ptr` should have been initialized with [`Pointable::init`].
178
    /// - `ptr` should not have yet been dropped by [`Pointable::drop`].
179
    /// - `ptr` should not be dereferenced by [`Pointable::deref`] or [`Pointable::deref_mut`]
180
    ///   concurrently.
181
    unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Self;
182
183
    /// Drops the object pointed to by the given pointer.
184
    ///
185
    /// # Safety
186
    ///
187
    /// - The given `ptr` should have been initialized with [`Pointable::init`].
188
    /// - `ptr` should not have yet been dropped by [`Pointable::drop`].
189
    /// - `ptr` should not be dereferenced by [`Pointable::deref`] or [`Pointable::deref_mut`]
190
    ///   concurrently.
191
    unsafe fn drop(ptr: usize);
192
}
193
194
impl<T> Pointable for T {
195
    const ALIGN: usize = mem::align_of::<T>();
196
197
    type Init = T;
198
199
3.94M
    unsafe fn init(init: Self::Init) -> usize {
200
3.94M
        Box::into_raw(Box::new(init)) as usize
201
3.94M
    }
<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
262
    unsafe fn init(init: Self::Init) -> usize {
200
262
        Box::into_raw(Box::new(init)) as usize
201
262
    }
<crossbeam_epoch::internal::Local as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
145
    unsafe fn init(init: Self::Init) -> usize {
200
145
        Box::into_raw(Box::new(init)) as usize
201
145
    }
<crossbeam_deque::deque::Buffer<injector::destructors::Elem> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
7
    unsafe fn init(init: Self::Init) -> usize {
200
7
        Box::into_raw(Box::new(init)) as usize
201
7
    }
<crossbeam_deque::deque::Buffer<usize> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
16
    unsafe fn init(init: Self::Init) -> usize {
200
16
        Box::into_raw(Box::new(init)) as usize
201
16
    }
<crossbeam_deque::deque::Buffer<i32> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
1
    unsafe fn init(init: Self::Init) -> usize {
200
1
        Box::into_raw(Box::new(init)) as usize
201
1
    }
<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
16
    unsafe fn init(init: Self::Init) -> usize {
200
16
        Box::into_raw(Box::new(init)) as usize
201
16
    }
<crossbeam_deque::deque::Buffer<fifo::destructors::Elem> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
19
    unsafe fn init(init: Self::Init) -> usize {
200
19
        Box::into_raw(Box::new(init)) as usize
201
19
    }
<crossbeam_deque::deque::Buffer<usize> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
33
    unsafe fn init(init: Self::Init) -> usize {
200
33
        Box::into_raw(Box::new(init)) as usize
201
33
    }
<crossbeam_deque::deque::Buffer<i32> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
2
    unsafe fn init(init: Self::Init) -> usize {
200
2
        Box::into_raw(Box::new(init)) as usize
201
2
    }
<crossbeam_deque::deque::Buffer<i32> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
22
    unsafe fn init(init: Self::Init) -> usize {
200
22
        Box::into_raw(Box::new(init)) as usize
201
22
    }
<crossbeam_deque::deque::Buffer<lifo::destructors::Elem> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
19
    unsafe fn init(init: Self::Init) -> usize {
200
19
        Box::into_raw(Box::new(init)) as usize
201
19
    }
<crossbeam_deque::deque::Buffer<usize> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
28
    unsafe fn init(init: Self::Init) -> usize {
200
28
        Box::into_raw(Box::new(init)) as usize
201
28
    }
<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
12
    unsafe fn init(init: Self::Init) -> usize {
200
12
        Box::into_raw(Box::new(init)) as usize
201
12
    }
<crossbeam_deque::deque::Buffer<i32> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
2
    unsafe fn init(init: Self::Init) -> usize {
200
2
        Box::into_raw(Box::new(init)) as usize
201
2
    }
<crossbeam_epoch::sync::list::Entry as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
8.14k
    unsafe fn init(init: Self::Init) -> usize {
200
8.14k
        Box::into_raw(Box::new(init)) as usize
201
8.14k
    }
<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
1
    unsafe fn init(init: Self::Init) -> usize {
200
1
        Box::into_raw(Box::new(init)) as usize
201
1
    }
<crossbeam_epoch::internal::Local as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
67
    unsafe fn init(init: Self::Init) -> usize {
200
67
        Box::into_raw(Box::new(init)) as usize
201
67
    }
<i32 as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
194k
    unsafe fn init(init: Self::Init) -> usize {
200
194k
        Box::into_raw(Box::new(init)) as usize
201
194k
    }
<crossbeam_epoch::collector::tests::count_drops::Elem as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
100k
    unsafe fn init(init: Self::Init) -> usize {
200
100k
        Box::into_raw(Box::new(init)) as usize
201
100k
    }
<crossbeam_epoch::collector::tests::stress::Elem as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
738k
    unsafe fn init(init: Self::Init) -> usize {
200
738k
        Box::into_raw(Box::new(init)) as usize
201
738k
    }
<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
5
    unsafe fn init(init: Self::Init) -> usize {
200
5
        Box::into_raw(Box::new(init)) as usize
201
5
    }
<crossbeam_epoch::sync::queue::Node<i64> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
2.83M
    unsafe fn init(init: Self::Init) -> usize {
200
2.83M
        Box::into_raw(Box::new(init)) as usize
201
2.83M
    }
<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag> as crossbeam_epoch::atomic::Pointable>::init
Line
Count
Source
199
64.7k
    unsafe fn init(init: Self::Init) -> usize {
200
64.7k
        Box::into_raw(Box::new(init)) as usize
201
64.7k
    }
202
203
27.8M
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
27.8M
        &*(ptr as *const T)
205
27.8M
    }
<crossbeam_skiplist::base::Node<i32, i32> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
403
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
403
        &*(ptr as *const T)
205
403
    }
<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
16.2k
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
16.2k
        &*(ptr as *const T)
205
16.2k
    }
<crossbeam_epoch::internal::Local as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
146
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
146
        &*(ptr as *const T)
205
146
    }
<crossbeam_epoch::sync::list::Entry as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
86.4k
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
86.4k
        &*(ptr as *const T)
205
86.4k
    }
<crossbeam_skiplist::base::Node<i32, ()> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
6
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
6
        &*(ptr as *const T)
205
6
    }
<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
25
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
25
        &*(ptr as *const T)
205
25
    }
<crossbeam_skiplist::base::Node<i32, i32> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
1.06k
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
1.06k
        &*(ptr as *const T)
205
1.06k
    }
<crossbeam_deque::deque::Buffer<usize> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
532k
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
532k
        &*(ptr as *const T)
205
532k
    }
<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
45.3k
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
45.3k
        &*(ptr as *const T)
205
45.3k
    }
<crossbeam_deque::deque::Buffer<i32> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
7
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
7
        &*(ptr as *const T)
205
7
    }
<crossbeam_deque::deque::Buffer<fifo::destructors::Elem> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
50.1k
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
50.1k
        &*(ptr as *const T)
205
50.1k
    }
<crossbeam_deque::deque::Buffer<i32> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
46
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
46
        &*(ptr as *const T)
205
46
    }
<crossbeam_deque::deque::Buffer<lifo::destructors::Elem> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
49.8k
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
49.8k
        &*(ptr as *const T)
205
49.8k
    }
<crossbeam_deque::deque::Buffer<usize> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
209k
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
209k
        &*(ptr as *const T)
205
209k
    }
<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
84.2k
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
84.2k
        &*(ptr as *const T)
205
84.2k
    }
<crossbeam_deque::deque::Buffer<i32> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
7
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
7
        &*(ptr as *const T)
205
7
    }
<crossbeam_epoch::sync::list::Entry as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
10.5M
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
10.5M
        &*(ptr as *const T)
205
10.5M
    }
<crossbeam_epoch::internal::Local as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
70
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
70
        &*(ptr as *const T)
205
70
    }
<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
3.93M
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
3.93M
        &*(ptr as *const T)
205
3.93M
    }
<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
1.95M
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
1.95M
        &*(ptr as *const T)
205
1.95M
    }
<crossbeam_epoch::sync::queue::Node<i64> as crossbeam_epoch::atomic::Pointable>::deref
Line
Count
Source
203
10.3M
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
204
10.3M
        &*(ptr as *const T)
205
10.3M
    }
206
207
0
    unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Self {
208
0
        &mut *(ptr as *mut T)
209
0
    }
210
211
3.80M
    unsafe fn drop(ptr: usize) {
212
3.80M
        drop(Box::from_raw(ptr as *mut T));
213
3.80M
    }
<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag> as crossbeam_epoch::atomic::Pointable>::drop
Line
Count
Source
211
133
    unsafe fn drop(ptr: usize) {
212
133
        drop(Box::from_raw(ptr as *mut T));
213
133
    }
<crossbeam_epoch::internal::Local as crossbeam_epoch::atomic::Pointable>::drop
Line
Count
Source
211
70
    unsafe fn drop(ptr: usize) {
212
70
        drop(Box::from_raw(ptr as *mut T));
213
70
    }
<crossbeam_epoch::sync::list::Entry as crossbeam_epoch::atomic::Pointable>::drop
Line
Count
Source
211
8.19k
    unsafe fn drop(ptr: usize) {
212
8.19k
        drop(Box::from_raw(ptr as *mut T));
213
8.19k
    }
<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem> as crossbeam_epoch::atomic::Pointable>::drop
Line
Count
Source
211
1
    unsafe fn drop(ptr: usize) {
212
1
        drop(Box::from_raw(ptr as *mut T));
213
1
    }
<crossbeam_epoch::internal::Local as crossbeam_epoch::atomic::Pointable>::drop
Line
Count
Source
211
65
    unsafe fn drop(ptr: usize) {
212
65
        drop(Box::from_raw(ptr as *mut T));
213
65
    }
<i32 as crossbeam_epoch::atomic::Pointable>::drop
Line
Count
Source
211
198k
    unsafe fn drop(ptr: usize) {
212
198k
        drop(Box::from_raw(ptr as *mut T));
213
198k
    }
<crossbeam_epoch::collector::tests::count_drops::Elem as crossbeam_epoch::atomic::Pointable>::drop
Line
Count
Source
211
100k
    unsafe fn drop(ptr: usize) {
212
100k
        drop(Box::from_raw(ptr as *mut T));
213
100k
    }
<crossbeam_epoch::collector::tests::stress::Elem as crossbeam_epoch::atomic::Pointable>::drop
Line
Count
Source
211
738k
    unsafe fn drop(ptr: usize) {
212
738k
        drop(Box::from_raw(ptr as *mut T));
213
738k
    }
<crossbeam_epoch::sync::queue::Node<i64> as crossbeam_epoch::atomic::Pointable>::drop
Line
Count
Source
211
2.69M
    unsafe fn drop(ptr: usize) {
212
2.69M
        drop(Box::from_raw(ptr as *mut T));
213
2.69M
    }
<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR> as crossbeam_epoch::atomic::Pointable>::drop
Line
Count
Source
211
5
    unsafe fn drop(ptr: usize) {
212
5
        drop(Box::from_raw(ptr as *mut T));
213
5
    }
<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag> as crossbeam_epoch::atomic::Pointable>::drop
Line
Count
Source
211
64.6k
    unsafe fn drop(ptr: usize) {
212
64.6k
        drop(Box::from_raw(ptr as *mut T));
213
64.6k
    }
214
}
215
216
/// Array with size.
217
///
218
/// # Memory layout
219
///
220
/// An array consisting of size and elements:
221
///
222
/// ```text
223
///          elements
224
///          |
225
///          |
226
/// ------------------------------------
227
/// | size | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
228
/// ------------------------------------
229
/// ```
230
///
231
/// Its memory layout is different from that of `Box<[T]>` in that size is in the allocation (not
232
/// along with pointer as in `Box<[T]>`).
233
///
234
/// Elements are not present in the type, but they will be in the allocation.
235
/// ```
236
///
237
// TODO(@jeehoonkang): once we bump the minimum required Rust version to 1.44 or newer, use
238
// [`alloc::alloc::Layout::extend`] instead.
239
#[repr(C)]
240
struct Array<T> {
241
    size: usize,
242
    elements: [MaybeUninit<T>; 0],
243
}
244
245
impl<T> Pointable for [MaybeUninit<T>] {
246
    const ALIGN: usize = mem::align_of::<Array<T>>();
247
248
    type Init = usize;
249
250
0
    unsafe fn init(size: Self::Init) -> usize {
251
0
        let size = mem::size_of::<Array<T>>() + mem::size_of::<MaybeUninit<T>>() * size;
252
0
        let align = mem::align_of::<Array<T>>();
253
0
        let layout = alloc::Layout::from_size_align(size, align).unwrap();
254
0
        let ptr = alloc::alloc(layout) as *mut Array<T>;
255
0
        (*ptr).size = size;
256
0
        ptr as usize
257
0
    }
258
259
0
    unsafe fn deref<'a>(ptr: usize) -> &'a Self {
260
0
        let array = &*(ptr as *const Array<T>);
261
0
        slice::from_raw_parts(array.elements.as_ptr() as *const _, array.size)
262
0
    }
263
264
0
    unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Self {
265
0
        let array = &*(ptr as *mut Array<T>);
266
0
        slice::from_raw_parts_mut(array.elements.as_ptr() as *mut _, array.size)
267
0
    }
268
269
0
    unsafe fn drop(ptr: usize) {
270
0
        let array = &*(ptr as *mut Array<T>);
271
0
        let size = mem::size_of::<Array<T>>() + mem::size_of::<MaybeUninit<T>>() * array.size;
272
0
        let align = mem::align_of::<Array<T>>();
273
0
        let layout = alloc::Layout::from_size_align(size, align).unwrap();
274
0
        alloc::dealloc(ptr as *mut u8, layout);
275
0
    }
276
}
277
278
/// An atomic pointer that can be safely shared between threads.
279
///
280
/// The pointer must be properly aligned. Since it is aligned, a tag can be stored into the unused
281
/// least significant bits of the address. For example, the tag for a pointer to a sized type `T`
282
/// should be less than `(1 << mem::align_of::<T>().trailing_zeros())`.
283
///
284
/// Any method that loads the pointer must be passed a reference to a [`Guard`].
285
///
286
/// Crossbeam supports dynamically sized types.  See [`Pointable`] for details.
287
pub struct Atomic<T: ?Sized + Pointable> {
288
    data: AtomicUsize,
289
    _marker: PhantomData<*mut T>,
290
}
291
292
unsafe impl<T: ?Sized + Pointable + Send + Sync> Send for Atomic<T> {}
293
unsafe impl<T: ?Sized + Pointable + Send + Sync> Sync for Atomic<T> {}
294
295
impl<T> Atomic<T> {
296
    /// Allocates `value` on the heap and returns a new atomic pointer pointing to it.
297
    ///
298
    /// # Examples
299
    ///
300
    /// ```
301
    /// use crossbeam_epoch::Atomic;
302
    ///
303
    /// let a = Atomic::new(1234);
304
    /// ```
305
105
    pub fn new(init: T) -> Atomic<T> {
306
105
        Self::init(init)
307
105
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::new
Line
Count
Source
305
16
    pub fn new(init: T) -> Atomic<T> {
306
16
        Self::init(init)
307
16
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>>::new
Line
Count
Source
305
7
    pub fn new(init: T) -> Atomic<T> {
306
7
        Self::init(init)
307
7
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::new
Line
Count
Source
305
1
    pub fn new(init: T) -> Atomic<T> {
306
1
        Self::init(init)
307
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::new
Line
Count
Source
305
2
    pub fn new(init: T) -> Atomic<T> {
306
2
        Self::init(init)
307
2
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::new
Line
Count
Source
305
9
    pub fn new(init: T) -> Atomic<T> {
306
9
        Self::init(init)
307
9
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::new
Line
Count
Source
305
18
    pub fn new(init: T) -> Atomic<T> {
306
18
        Self::init(init)
307
18
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::new
Line
Count
Source
305
1
    pub fn new(init: T) -> Atomic<T> {
306
1
        Self::init(init)
307
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::new
Line
Count
Source
305
21
    pub fn new(init: T) -> Atomic<T> {
306
21
        Self::init(init)
307
21
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::new
Line
Count
Source
305
9
    pub fn new(init: T) -> Atomic<T> {
306
9
        Self::init(init)
307
9
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::new
Line
Count
Source
305
2
    pub fn new(init: T) -> Atomic<T> {
306
2
        Self::init(init)
307
2
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::new
Line
Count
Source
305
1
    pub fn new(init: T) -> Atomic<T> {
306
1
        Self::init(init)
307
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::new
Line
Count
Source
305
18
    pub fn new(init: T) -> Atomic<T> {
306
18
        Self::init(init)
307
18
    }
308
}
309
310
impl<T: ?Sized + Pointable> Atomic<T> {
311
    /// Allocates `value` on the heap and returns a new atomic pointer pointing to it.
312
    ///
313
    /// # Examples
314
    ///
315
    /// ```
316
    /// use crossbeam_epoch::Atomic;
317
    ///
318
    /// let a = Atomic::<i32>::init(1234);
319
    /// ```
320
105
    pub fn init(init: T::Init) -> Atomic<T> {
321
105
        Self::from(Owned::init(init))
322
105
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>>::init
Line
Count
Source
320
7
    pub fn init(init: T::Init) -> Atomic<T> {
321
7
        Self::from(Owned::init(init))
322
7
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::init
Line
Count
Source
320
16
    pub fn init(init: T::Init) -> Atomic<T> {
321
16
        Self::from(Owned::init(init))
322
16
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::init
Line
Count
Source
320
1
    pub fn init(init: T::Init) -> Atomic<T> {
321
1
        Self::from(Owned::init(init))
322
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::init
Line
Count
Source
320
2
    pub fn init(init: T::Init) -> Atomic<T> {
321
2
        Self::from(Owned::init(init))
322
2
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::init
Line
Count
Source
320
1
    pub fn init(init: T::Init) -> Atomic<T> {
321
1
        Self::from(Owned::init(init))
322
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::init
Line
Count
Source
320
9
    pub fn init(init: T::Init) -> Atomic<T> {
321
9
        Self::from(Owned::init(init))
322
9
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::init
Line
Count
Source
320
18
    pub fn init(init: T::Init) -> Atomic<T> {
321
18
        Self::from(Owned::init(init))
322
18
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::init
Line
Count
Source
320
21
    pub fn init(init: T::Init) -> Atomic<T> {
321
21
        Self::from(Owned::init(init))
322
21
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::init
Line
Count
Source
320
2
    pub fn init(init: T::Init) -> Atomic<T> {
321
2
        Self::from(Owned::init(init))
322
2
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::init
Line
Count
Source
320
9
    pub fn init(init: T::Init) -> Atomic<T> {
321
9
        Self::from(Owned::init(init))
322
9
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::init
Line
Count
Source
320
18
    pub fn init(init: T::Init) -> Atomic<T> {
321
18
        Self::from(Owned::init(init))
322
18
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::init
Line
Count
Source
320
1
    pub fn init(init: T::Init) -> Atomic<T> {
321
1
        Self::from(Owned::init(init))
322
1
    }
323
324
    /// Returns a new atomic pointer pointing to the tagged pointer `data`.
325
107
    fn from_usize(data: usize) -> Self {
326
107
        Self {
327
107
            data: AtomicUsize::new(data),
328
107
            _marker: PhantomData,
329
107
        }
330
107
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::from_usize
Line
Count
Source
325
16
    fn from_usize(data: usize) -> Self {
326
16
        Self {
327
16
            data: AtomicUsize::new(data),
328
16
            _marker: PhantomData,
329
16
        }
330
16
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>>::from_usize
Line
Count
Source
325
7
    fn from_usize(data: usize) -> Self {
326
7
        Self {
327
7
            data: AtomicUsize::new(data),
328
7
            _marker: PhantomData,
329
7
        }
330
7
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::from_usize
Line
Count
Source
325
1
    fn from_usize(data: usize) -> Self {
326
1
        Self {
327
1
            data: AtomicUsize::new(data),
328
1
            _marker: PhantomData,
329
1
        }
330
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::from_usize
Line
Count
Source
325
1
    fn from_usize(data: usize) -> Self {
326
1
        Self {
327
1
            data: AtomicUsize::new(data),
328
1
            _marker: PhantomData,
329
1
        }
330
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::from_usize
Line
Count
Source
325
2
    fn from_usize(data: usize) -> Self {
326
2
        Self {
327
2
            data: AtomicUsize::new(data),
328
2
            _marker: PhantomData,
329
2
        }
330
2
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::from_usize
Line
Count
Source
325
19
    fn from_usize(data: usize) -> Self {
326
19
        Self {
327
19
            data: AtomicUsize::new(data),
328
19
            _marker: PhantomData,
329
19
        }
330
19
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::from_usize
Line
Count
Source
325
9
    fn from_usize(data: usize) -> Self {
326
9
        Self {
327
9
            data: AtomicUsize::new(data),
328
9
            _marker: PhantomData,
329
9
        }
330
9
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::from_usize
Line
Count
Source
325
22
    fn from_usize(data: usize) -> Self {
326
22
        Self {
327
22
            data: AtomicUsize::new(data),
328
22
            _marker: PhantomData,
329
22
        }
330
22
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::from_usize
Line
Count
Source
325
9
    fn from_usize(data: usize) -> Self {
326
9
        Self {
327
9
            data: AtomicUsize::new(data),
328
9
            _marker: PhantomData,
329
9
        }
330
9
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::from_usize
Line
Count
Source
325
2
    fn from_usize(data: usize) -> Self {
326
2
        Self {
327
2
            data: AtomicUsize::new(data),
328
2
            _marker: PhantomData,
329
2
        }
330
2
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::from_usize
Line
Count
Source
325
1
    fn from_usize(data: usize) -> Self {
326
1
        Self {
327
1
            data: AtomicUsize::new(data),
328
1
            _marker: PhantomData,
329
1
        }
330
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::from_usize
Line
Count
Source
325
18
    fn from_usize(data: usize) -> Self {
326
18
        Self {
327
18
            data: AtomicUsize::new(data),
328
18
            _marker: PhantomData,
329
18
        }
330
18
    }
331
332
    /// Returns a new null atomic pointer.
333
    ///
334
    /// # Examples
335
    ///
336
    /// ```
337
    /// use crossbeam_epoch::Atomic;
338
    ///
339
    /// let a = Atomic::<i32>::null();
340
    /// ```
341
    ///
342
    #[cfg_attr(all(feature = "nightly", not(loom_crossbeam)), const_fn::const_fn)]
343
2.92M
    pub fn null() -> Atomic<T> {
344
2.92M
        Self {
345
2.92M
            data: AtomicUsize::new(0),
346
2.92M
            _marker: PhantomData,
347
2.92M
        }
348
2.92M
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::null
Line
Count
Source
343
67
    pub fn null() -> Atomic<T> {
344
67
        Self {
345
67
            data: AtomicUsize::new(0),
346
67
            _marker: PhantomData,
347
67
        }
348
67
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::null
Line
Count
Source
343
347
    pub fn null() -> Atomic<T> {
344
347
        Self {
345
347
            data: AtomicUsize::new(0),
346
347
            _marker: PhantomData,
347
347
        }
348
347
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::null
Line
Count
Source
343
189
    pub fn null() -> Atomic<T> {
344
189
        Self {
345
189
            data: AtomicUsize::new(0),
346
189
            _marker: PhantomData,
347
189
        }
348
189
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, ()>>>::null
Line
Count
Source
343
32
    pub fn null() -> Atomic<T> {
344
32
        Self {
345
32
            data: AtomicUsize::new(0),
346
32
            _marker: PhantomData,
347
32
        }
348
32
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::null
Line
Count
Source
343
545
    pub fn null() -> Atomic<T> {
344
545
        Self {
345
545
            data: AtomicUsize::new(0),
346
545
            _marker: PhantomData,
347
545
        }
348
545
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<alloc::string::String, alloc::boxed::Box<i32>>>>::null
Line
Count
Source
343
32
    pub fn null() -> Atomic<T> {
344
32
        Self {
345
32
            data: AtomicUsize::new(0),
346
32
            _marker: PhantomData,
347
32
        }
348
32
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::null
Line
Count
Source
343
32
    pub fn null() -> Atomic<T> {
344
32
        Self {
345
32
            data: AtomicUsize::new(0),
346
32
            _marker: PhantomData,
347
32
        }
348
32
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::null
Line
Count
Source
343
7
    pub fn null() -> Atomic<T> {
344
7
        Self {
345
7
            data: AtomicUsize::new(0),
346
7
            _marker: PhantomData,
347
7
        }
348
7
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::null
Line
Count
Source
343
8.27k
    pub fn null() -> Atomic<T> {
344
8.27k
        Self {
345
8.27k
            data: AtomicUsize::new(0),
346
8.27k
            _marker: PhantomData,
347
8.27k
        }
348
8.27k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<i64>>>::null
Line
Count
Source
343
2.84M
    pub fn null() -> Atomic<T> {
344
2.84M
        Self {
345
2.84M
            data: AtomicUsize::new(0),
346
2.84M
            _marker: PhantomData,
347
2.84M
        }
348
2.84M
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::null
Line
Count
Source
343
64.9k
    pub fn null() -> Atomic<T> {
344
64.9k
        Self {
345
64.9k
            data: AtomicUsize::new(0),
346
64.9k
            _marker: PhantomData,
347
64.9k
        }
348
64.9k
    }
349
350
    /// Loads a `Shared` from the atomic pointer.
351
    ///
352
    /// This method takes an [`Ordering`] argument which describes the memory ordering of this
353
    /// operation.
354
    ///
355
    /// # Examples
356
    ///
357
    /// ```
358
    /// use crossbeam_epoch::{self as epoch, Atomic};
359
    /// use std::sync::atomic::Ordering::SeqCst;
360
    ///
361
    /// let a = Atomic::new(1234);
362
    /// let guard = &epoch::pin();
363
    /// let p = a.load(SeqCst, guard);
364
    /// ```
365
40.7M
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
40.7M
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
40.7M
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::load
Line
Count
Source
365
118
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
118
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
118
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::load
Line
Count
Source
365
20.3k
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
20.3k
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
20.3k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::load
Line
Count
Source
365
95.9k
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
95.9k
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
95.9k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>>::load
Line
Count
Source
365
8
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
8
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
8
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::load
Line
Count
Source
365
13
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
13
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
13
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, ()>>>::load
Line
Count
Source
365
10
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
10
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
10
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::load
Line
Count
Source
365
595
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
595
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
595
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<alloc::string::String, alloc::boxed::Box<i32>>>>::load
Line
Count
Source
365
1
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
1
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::load
Line
Count
Source
365
24
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
24
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
24
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::load
Line
Count
Source
365
1
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
1
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::load
Line
Count
Source
365
9
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
9
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
9
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::load
Line
Count
Source
365
45.3k
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
45.3k
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
45.3k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::load
Line
Count
Source
365
162k
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
162k
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
162k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::load
Line
Count
Source
365
443
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
443
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
443
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::load
Line
Count
Source
365
36
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
36
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
36
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>>>::load
Line
Count
Source
365
9
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
9
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
9
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::load
Line
Count
Source
365
1.27k
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
1.27k
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
1.27k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::load
Line
Count
Source
365
181k
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
181k
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
181k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::load
Line
Count
Source
365
84.5k
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
84.5k
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
84.5k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::load
Line
Count
Source
365
3.84M
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
3.84M
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
3.84M
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::load
Line
Count
Source
365
7.03M
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
7.03M
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
7.03M
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::load
Line
Count
Source
365
13.8M
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
13.8M
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
13.8M
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<i64>>>::load
Line
Count
Source
365
15.4M
    pub fn load<'g>(&self, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
366
15.4M
        unsafe { Shared::from_usize(self.data.load(ord)) }
367
15.4M
    }
368
369
    /// Loads a `Shared` from the atomic pointer using a "consume" memory ordering.
370
    ///
371
    /// This is similar to the "acquire" ordering, except that an ordering is
372
    /// only guaranteed with operations that "depend on" the result of the load.
373
    /// However consume loads are usually much faster than acquire loads on
374
    /// architectures with a weak memory model since they don't require memory
375
    /// fence instructions.
376
    ///
377
    /// The exact definition of "depend on" is a bit vague, but it works as you
378
    /// would expect in practice since a lot of software, especially the Linux
379
    /// kernel, rely on this behavior.
380
    ///
381
    /// # Examples
382
    ///
383
    /// ```
384
    /// use crossbeam_epoch::{self as epoch, Atomic};
385
    ///
386
    /// let a = Atomic::new(1234);
387
    /// let guard = &epoch::pin();
388
    /// let p = a.load_consume(guard);
389
    /// ```
390
2.40k
    pub fn load_consume<'g>(&self, _: &'g Guard) -> Shared<'g, T> {
391
2.40k
        unsafe { Shared::from_usize(self.data.load_consume()) }
392
2.40k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::load_consume
Line
Count
Source
390
684
    pub fn load_consume<'g>(&self, _: &'g Guard) -> Shared<'g, T> {
391
684
        unsafe { Shared::from_usize(self.data.load_consume()) }
392
684
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, ()>>>::load_consume
Line
Count
Source
390
5
    pub fn load_consume<'g>(&self, _: &'g Guard) -> Shared<'g, T> {
391
5
        unsafe { Shared::from_usize(self.data.load_consume()) }
392
5
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::load_consume
Line
Count
Source
390
1.69k
    pub fn load_consume<'g>(&self, _: &'g Guard) -> Shared<'g, T> {
391
1.69k
        unsafe { Shared::from_usize(self.data.load_consume()) }
392
1.69k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::load_consume
Line
Count
Source
390
27
    pub fn load_consume<'g>(&self, _: &'g Guard) -> Shared<'g, T> {
391
27
        unsafe { Shared::from_usize(self.data.load_consume()) }
392
27
    }
393
394
    /// Stores a `Shared` or `Owned` pointer into the atomic pointer.
395
    ///
396
    /// This method takes an [`Ordering`] argument which describes the memory ordering of this
397
    /// operation.
398
    ///
399
    /// # Examples
400
    ///
401
    /// ```
402
    /// use crossbeam_epoch::{Atomic, Owned, Shared};
403
    /// use std::sync::atomic::Ordering::SeqCst;
404
    ///
405
    /// let a = Atomic::new(1234);
406
    /// a.store(Shared::null(), SeqCst);
407
    /// a.store(Owned::new(1234), SeqCst);
408
    /// ```
409
10.5k
    pub fn store<P: Pointer<T>>(&self, new: P, ord: Ordering) {
410
10.5k
        self.data.store(new.into_usize(), ord);
411
10.5k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::store::<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>
Line
Count
Source
409
20
    pub fn store<P: Pointer<T>>(&self, new: P, ord: Ordering) {
410
20
        self.data.store(new.into_usize(), ord);
411
20
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::store::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>
Line
Count
Source
409
84
    pub fn store<P: Pointer<T>>(&self, new: P, ord: Ordering) {
410
84
        self.data.store(new.into_usize(), ord);
411
84
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::store::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>
Line
Count
Source
409
146
    pub fn store<P: Pointer<T>>(&self, new: P, ord: Ordering) {
410
146
        self.data.store(new.into_usize(), ord);
411
146
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, ()>>>::store::<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, ()>>>
Line
Count
Source
409
3
    pub fn store<P: Pointer<T>>(&self, new: P, ord: Ordering) {
410
3
        self.data.store(new.into_usize(), ord);
411
3
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::store::<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>
Line
Count
Source
409
7
    pub fn store<P: Pointer<T>>(&self, new: P, ord: Ordering) {
410
7
        self.data.store(new.into_usize(), ord);
411
7
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::store::<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>
Line
Count
Source
409
155
    pub fn store<P: Pointer<T>>(&self, new: P, ord: Ordering) {
410
155
        self.data.store(new.into_usize(), ord);
411
155
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::store::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>
Line
Count
Source
409
31
    pub fn store<P: Pointer<T>>(&self, new: P, ord: Ordering) {
410
31
        self.data.store(new.into_usize(), ord);
411
31
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<i64>>>::store::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<i64>>>
Line
Count
Source
409
20
    pub fn store<P: Pointer<T>>(&self, new: P, ord: Ordering) {
410
20
        self.data.store(new.into_usize(), ord);
411
20
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::store::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>
Line
Count
Source
409
10.0k
    pub fn store<P: Pointer<T>>(&self, new: P, ord: Ordering) {
410
10.0k
        self.data.store(new.into_usize(), ord);
411
10.0k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::store::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>
Line
Count
Source
409
2
    pub fn store<P: Pointer<T>>(&self, new: P, ord: Ordering) {
410
2
        self.data.store(new.into_usize(), ord);
411
2
    }
412
413
    /// Stores a `Shared` or `Owned` pointer into the atomic pointer, returning the previous
414
    /// `Shared`.
415
    ///
416
    /// This method takes an [`Ordering`] argument which describes the memory ordering of this
417
    /// operation.
418
    ///
419
    /// # Examples
420
    ///
421
    /// ```
422
    /// use crossbeam_epoch::{self as epoch, Atomic, Shared};
423
    /// use std::sync::atomic::Ordering::SeqCst;
424
    ///
425
    /// let a = Atomic::new(1234);
426
    /// let guard = &epoch::pin();
427
    /// let p = a.swap(Shared::null(), SeqCst, guard);
428
    /// ```
429
72
    pub fn swap<'g, P: Pointer<T>>(&self, new: P, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
430
72
        unsafe { Shared::from_usize(self.data.swap(new.into_usize(), ord)) }
431
72
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::swap::<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>>>
Line
Count
Source
429
16
    pub fn swap<'g, P: Pointer<T>>(&self, new: P, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
430
16
        unsafe { Shared::from_usize(self.data.swap(new.into_usize(), ord)) }
431
16
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::swap::<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>
Line
Count
Source
429
10
    pub fn swap<'g, P: Pointer<T>>(&self, new: P, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
430
10
        unsafe { Shared::from_usize(self.data.swap(new.into_usize(), ord)) }
431
10
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::swap::<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>
Line
Count
Source
429
15
    pub fn swap<'g, P: Pointer<T>>(&self, new: P, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
430
15
        unsafe { Shared::from_usize(self.data.swap(new.into_usize(), ord)) }
431
15
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::swap::<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>
Line
Count
Source
429
11
    pub fn swap<'g, P: Pointer<T>>(&self, new: P, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
430
11
        unsafe { Shared::from_usize(self.data.swap(new.into_usize(), ord)) }
431
11
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::swap::<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>
Line
Count
Source
429
10
    pub fn swap<'g, P: Pointer<T>>(&self, new: P, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
430
10
        unsafe { Shared::from_usize(self.data.swap(new.into_usize(), ord)) }
431
10
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>>>::swap::<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>>>
Line
Count
Source
429
10
    pub fn swap<'g, P: Pointer<T>>(&self, new: P, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
430
10
        unsafe { Shared::from_usize(self.data.swap(new.into_usize(), ord)) }
431
10
    }
432
433
    /// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current
434
    /// value is the same as `current`. The tag is also taken into account, so two pointers to the
435
    /// same object, but with different tags, will not be considered equal.
436
    ///
437
    /// The return value is a result indicating whether the new pointer was written. On success the
438
    /// pointer that was written is returned. On failure the actual current value and `new` are
439
    /// returned.
440
    ///
441
    /// This method takes two `Ordering` arguments to describe the memory
442
    /// ordering of this operation. `success` describes the required ordering for the
443
    /// read-modify-write operation that takes place if the comparison with `current` succeeds.
444
    /// `failure` describes the required ordering for the load operation that takes place when
445
    /// the comparison fails. Using `Acquire` as success ordering makes the store part
446
    /// of this operation `Relaxed`, and using `Release` makes the successful load
447
    /// `Relaxed`. The failure ordering can only be `SeqCst`, `Acquire` or `Relaxed`
448
    /// and must be equivalent to or weaker than the success ordering.
449
    ///
450
    /// # Examples
451
    ///
452
    /// ```
453
    /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared};
454
    /// use std::sync::atomic::Ordering::SeqCst;
455
    ///
456
    /// let a = Atomic::new(1234);
457
    ///
458
    /// let guard = &epoch::pin();
459
    /// let curr = a.load(SeqCst, guard);
460
    /// let res1 = a.compare_exchange(curr, Shared::null(), SeqCst, SeqCst, guard);
461
    /// let res2 = a.compare_exchange(curr, Owned::new(5678), SeqCst, SeqCst, guard);
462
    /// ```
463
8.31M
    pub fn compare_exchange<'g, P>(
464
8.31M
        &self,
465
8.31M
        current: Shared<'_, T>,
466
8.31M
        new: P,
467
8.31M
        success: Ordering,
468
8.31M
        failure: Ordering,
469
8.31M
        _: &'g Guard,
470
8.31M
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
471
8.31M
    where
472
8.31M
        P: Pointer<T>,
473
8.31M
    {
474
8.31M
        let new = new.into_usize();
475
8.31M
        self.data
476
8.31M
            .compare_exchange(current.into_usize(), new, success, failure)
477
8.67M
            .map(|_| unsafe { Shared::from_usize(new) })
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::{closure#0}
Line
Count
Source
477
33
            .map(|_| unsafe { Shared::from_usize(new) })
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::{closure#0}
Line
Count
Source
477
607
            .map(|_| unsafe { Shared::from_usize(new) })
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::{closure#0}
Line
Count
Source
477
97
            .map(|_| unsafe { Shared::from_usize(new) })
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, ()>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, ()>>>::{closure#0}
Line
Count
Source
477
3
            .map(|_| unsafe { Shared::from_usize(new) })
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::{closure#0}
Line
Count
Source
477
222
            .map(|_| unsafe { Shared::from_usize(new) })
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::{closure#0}
Line
Count
Source
477
10
            .map(|_| unsafe { Shared::from_usize(new) })
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<i64>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<i64>>>::{closure#0}
Line
Count
Source
477
8.47M
            .map(|_| unsafe { Shared::from_usize(new) })
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::{closure#0}
Line
Count
Source
477
194k
            .map(|_| unsafe { Shared::from_usize(new) })
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::{closure#0}
Line
Count
Source
477
12
            .map(|_| unsafe { Shared::from_usize(new) })
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::{closure#0}
Line
Count
Source
477
8.23k
            .map(|_| unsafe { Shared::from_usize(new) })
478
8.31M
            .map_err(|current| unsafe {
479
399k
                CompareExchangeError {
480
399k
                    current: Shared::from_usize(current),
481
399k
                    new: P::from_usize(new),
482
399k
                }
483
8.31M
            })
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::{closure#1}
Line
Count
Source
478
2
            .map_err(|current| unsafe {
479
2
                CompareExchangeError {
480
2
                    current: Shared::from_usize(current),
481
2
                    new: P::from_usize(new),
482
2
                }
483
2
            })
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::{closure#1}
Line
Count
Source
478
27
            .map_err(|current| unsafe {
479
27
                CompareExchangeError {
480
27
                    current: Shared::from_usize(current),
481
27
                    new: P::from_usize(new),
482
27
                }
483
27
            })
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<i64>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<i64>>>::{closure#1}
Line
Count
Source
478
397k
            .map_err(|current| unsafe {
479
397k
                CompareExchangeError {
480
397k
                    current: Shared::from_usize(current),
481
397k
                    new: P::from_usize(new),
482
397k
                }
483
397k
            })
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::{closure#1}
Line
Count
Source
478
6
            .map_err(|current| unsafe {
479
6
                CompareExchangeError {
480
6
                    current: Shared::from_usize(current),
481
6
                    new: P::from_usize(new),
482
6
                }
483
6
            })
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::{closure#1}
Line
Count
Source
478
1.94k
            .map_err(|current| unsafe {
479
1.94k
                CompareExchangeError {
480
1.94k
                    current: Shared::from_usize(current),
481
1.94k
                    new: P::from_usize(new),
482
1.94k
                }
483
1.94k
            })
484
8.31M
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>
Line
Count
Source
463
33
    pub fn compare_exchange<'g, P>(
464
33
        &self,
465
33
        current: Shared<'_, T>,
466
33
        new: P,
467
33
        success: Ordering,
468
33
        failure: Ordering,
469
33
        _: &'g Guard,
470
33
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
471
33
    where
472
33
        P: Pointer<T>,
473
33
    {
474
33
        let new = new.into_usize();
475
33
        self.data
476
33
            .compare_exchange(current.into_usize(), new, success, failure)
477
33
            .map(|_| unsafe { Shared::from_usize(new) })
478
33
            .map_err(|current| unsafe {
479
                CompareExchangeError {
480
                    current: Shared::from_usize(current),
481
                    new: P::from_usize(new),
482
                }
483
33
            })
484
33
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>
Line
Count
Source
463
99
    pub fn compare_exchange<'g, P>(
464
99
        &self,
465
99
        current: Shared<'_, T>,
466
99
        new: P,
467
99
        success: Ordering,
468
99
        failure: Ordering,
469
99
        _: &'g Guard,
470
99
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
471
99
    where
472
99
        P: Pointer<T>,
473
99
    {
474
99
        let new = new.into_usize();
475
99
        self.data
476
99
            .compare_exchange(current.into_usize(), new, success, failure)
477
99
            .map(|_| unsafe { Shared::from_usize(new) })
478
99
            .map_err(|current| unsafe {
479
                CompareExchangeError {
480
                    current: Shared::from_usize(current),
481
                    new: P::from_usize(new),
482
                }
483
99
            })
484
99
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>
Line
Count
Source
463
631
    pub fn compare_exchange<'g, P>(
464
631
        &self,
465
631
        current: Shared<'_, T>,
466
631
        new: P,
467
631
        success: Ordering,
468
631
        failure: Ordering,
469
631
        _: &'g Guard,
470
631
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
471
631
    where
472
631
        P: Pointer<T>,
473
631
    {
474
631
        let new = new.into_usize();
475
631
        self.data
476
631
            .compare_exchange(current.into_usize(), new, success, failure)
477
631
            .map(|_| unsafe { Shared::from_usize(new) })
478
631
            .map_err(|current| unsafe {
479
                CompareExchangeError {
480
                    current: Shared::from_usize(current),
481
                    new: P::from_usize(new),
482
                }
483
631
            })
484
631
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, ()>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, ()>>>
Line
Count
Source
463
3
    pub fn compare_exchange<'g, P>(
464
3
        &self,
465
3
        current: Shared<'_, T>,
466
3
        new: P,
467
3
        success: Ordering,
468
3
        failure: Ordering,
469
3
        _: &'g Guard,
470
3
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
471
3
    where
472
3
        P: Pointer<T>,
473
3
    {
474
3
        let new = new.into_usize();
475
3
        self.data
476
3
            .compare_exchange(current.into_usize(), new, success, failure)
477
3
            .map(|_| unsafe { Shared::from_usize(new) })
478
3
            .map_err(|current| unsafe {
479
                CompareExchangeError {
480
                    current: Shared::from_usize(current),
481
                    new: P::from_usize(new),
482
                }
483
3
            })
484
3
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>
Line
Count
Source
463
10
    pub fn compare_exchange<'g, P>(
464
10
        &self,
465
10
        current: Shared<'_, T>,
466
10
        new: P,
467
10
        success: Ordering,
468
10
        failure: Ordering,
469
10
        _: &'g Guard,
470
10
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
471
10
    where
472
10
        P: Pointer<T>,
473
10
    {
474
10
        let new = new.into_usize();
475
10
        self.data
476
10
            .compare_exchange(current.into_usize(), new, success, failure)
477
10
            .map(|_| unsafe { Shared::from_usize(new) })
478
10
            .map_err(|current| unsafe {
479
                CompareExchangeError {
480
                    current: Shared::from_usize(current),
481
                    new: P::from_usize(new),
482
                }
483
10
            })
484
10
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>
Line
Count
Source
463
221
    pub fn compare_exchange<'g, P>(
464
221
        &self,
465
221
        current: Shared<'_, T>,
466
221
        new: P,
467
221
        success: Ordering,
468
221
        failure: Ordering,
469
221
        _: &'g Guard,
470
221
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
471
221
    where
472
221
        P: Pointer<T>,
473
221
    {
474
221
        let new = new.into_usize();
475
221
        self.data
476
221
            .compare_exchange(current.into_usize(), new, success, failure)
477
221
            .map(|_| unsafe { Shared::from_usize(new) })
478
221
            .map_err(|current| unsafe {
479
                CompareExchangeError {
480
                    current: Shared::from_usize(current),
481
                    new: P::from_usize(new),
482
                }
483
221
            })
484
221
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<i64>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<i64>>>
Line
Count
Source
463
8.10M
    pub fn compare_exchange<'g, P>(
464
8.10M
        &self,
465
8.10M
        current: Shared<'_, T>,
466
8.10M
        new: P,
467
8.10M
        success: Ordering,
468
8.10M
        failure: Ordering,
469
8.10M
        _: &'g Guard,
470
8.10M
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
471
8.10M
    where
472
8.10M
        P: Pointer<T>,
473
8.10M
    {
474
8.10M
        let new = new.into_usize();
475
8.10M
        self.data
476
8.10M
            .compare_exchange(current.into_usize(), new, success, failure)
477
8.10M
            .map(|_| unsafe { Shared::from_usize(new) })
478
8.10M
            .map_err(|current| unsafe {
479
                CompareExchangeError {
480
                    current: Shared::from_usize(current),
481
                    new: P::from_usize(new),
482
                }
483
8.10M
            })
484
8.10M
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>
Line
Count
Source
463
8.23k
    pub fn compare_exchange<'g, P>(
464
8.23k
        &self,
465
8.23k
        current: Shared<'_, T>,
466
8.23k
        new: P,
467
8.23k
        success: Ordering,
468
8.23k
        failure: Ordering,
469
8.23k
        _: &'g Guard,
470
8.23k
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
471
8.23k
    where
472
8.23k
        P: Pointer<T>,
473
8.23k
    {
474
8.23k
        let new = new.into_usize();
475
8.23k
        self.data
476
8.23k
            .compare_exchange(current.into_usize(), new, success, failure)
477
8.23k
            .map(|_| unsafe { Shared::from_usize(new) })
478
8.23k
            .map_err(|current| unsafe {
479
                CompareExchangeError {
480
                    current: Shared::from_usize(current),
481
                    new: P::from_usize(new),
482
                }
483
8.23k
            })
484
8.23k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>
Line
Count
Source
463
12
    pub fn compare_exchange<'g, P>(
464
12
        &self,
465
12
        current: Shared<'_, T>,
466
12
        new: P,
467
12
        success: Ordering,
468
12
        failure: Ordering,
469
12
        _: &'g Guard,
470
12
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
471
12
    where
472
12
        P: Pointer<T>,
473
12
    {
474
12
        let new = new.into_usize();
475
12
        self.data
476
12
            .compare_exchange(current.into_usize(), new, success, failure)
477
12
            .map(|_| unsafe { Shared::from_usize(new) })
478
12
            .map_err(|current| unsafe {
479
                CompareExchangeError {
480
                    current: Shared::from_usize(current),
481
                    new: P::from_usize(new),
482
                }
483
12
            })
484
12
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::compare_exchange::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>
Line
Count
Source
463
196k
    pub fn compare_exchange<'g, P>(
464
196k
        &self,
465
196k
        current: Shared<'_, T>,
466
196k
        new: P,
467
196k
        success: Ordering,
468
196k
        failure: Ordering,
469
196k
        _: &'g Guard,
470
196k
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
471
196k
    where
472
196k
        P: Pointer<T>,
473
196k
    {
474
196k
        let new = new.into_usize();
475
196k
        self.data
476
196k
            .compare_exchange(current.into_usize(), new, success, failure)
477
196k
            .map(|_| unsafe { Shared::from_usize(new) })
478
196k
            .map_err(|current| unsafe {
479
                CompareExchangeError {
480
                    current: Shared::from_usize(current),
481
                    new: P::from_usize(new),
482
                }
483
196k
            })
484
196k
    }
485
486
    /// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current
487
    /// value is the same as `current`. The tag is also taken into account, so two pointers to the
488
    /// same object, but with different tags, will not be considered equal.
489
    ///
490
    /// Unlike [`compare_exchange`], this method is allowed to spuriously fail even when comparison
491
    /// succeeds, which can result in more efficient code on some platforms.  The return value is a
492
    /// result indicating whether the new pointer was written. On success the pointer that was
493
    /// written is returned. On failure the actual current value and `new` are returned.
494
    ///
495
    /// This method takes two `Ordering` arguments to describe the memory
496
    /// ordering of this operation. `success` describes the required ordering for the
497
    /// read-modify-write operation that takes place if the comparison with `current` succeeds.
498
    /// `failure` describes the required ordering for the load operation that takes place when
499
    /// the comparison fails. Using `Acquire` as success ordering makes the store part
500
    /// of this operation `Relaxed`, and using `Release` makes the successful load
501
    /// `Relaxed`. The failure ordering can only be `SeqCst`, `Acquire` or `Relaxed`
502
    /// and must be equivalent to or weaker than the success ordering.
503
    ///
504
    /// [`compare_exchange`]: Atomic::compare_exchange
505
    ///
506
    /// # Examples
507
    ///
508
    /// ```
509
    /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared};
510
    /// use std::sync::atomic::Ordering::SeqCst;
511
    ///
512
    /// let a = Atomic::new(1234);
513
    /// let guard = &epoch::pin();
514
    ///
515
    /// let mut new = Owned::new(5678);
516
    /// let mut ptr = a.load(SeqCst, guard);
517
    /// loop {
518
    ///     match a.compare_exchange_weak(ptr, new, SeqCst, SeqCst, guard) {
519
    ///         Ok(p) => {
520
    ///             ptr = p;
521
    ///             break;
522
    ///         }
523
    ///         Err(err) => {
524
    ///             ptr = err.current;
525
    ///             new = err.new;
526
    ///         }
527
    ///     }
528
    /// }
529
    ///
530
    /// let mut curr = a.load(SeqCst, guard);
531
    /// loop {
532
    ///     match a.compare_exchange_weak(curr, Shared::null(), SeqCst, SeqCst, guard) {
533
    ///         Ok(_) => break,
534
    ///         Err(err) => curr = err.current,
535
    ///     }
536
    /// }
537
    /// ```
538
10.4k
    pub fn compare_exchange_weak<'g, P>(
539
10.4k
        &self,
540
10.4k
        current: Shared<'_, T>,
541
10.4k
        new: P,
542
10.4k
        success: Ordering,
543
10.4k
        failure: Ordering,
544
10.4k
        _: &'g Guard,
545
10.4k
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
546
10.4k
    where
547
10.4k
        P: Pointer<T>,
548
10.4k
    {
549
10.4k
        let new = new.into_usize();
550
10.4k
        self.data
551
10.4k
            .compare_exchange_weak(current.into_usize(), new, success, failure)
552
10.4k
            .map(|_| 
unsafe { Shared::from_usize(new) }8.41k
)
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::compare_exchange_weak::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::{closure#0}
Line
Count
Source
552
146
            .map(|_| unsafe { Shared::from_usize(new) })
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::compare_exchange_weak::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::{closure#0}
Line
Count
Source
552
8.26k
            .map(|_| unsafe { Shared::from_usize(new) })
553
10.4k
            .map_err(|current| unsafe {
554
2.64k
                CompareExchangeError {
555
2.64k
                    current: Shared::from_usize(current),
556
2.64k
                    new: P::from_usize(new),
557
2.64k
                }
558
10.4k
            })
559
10.4k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::compare_exchange_weak::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>
Line
Count
Source
538
146
    pub fn compare_exchange_weak<'g, P>(
539
146
        &self,
540
146
        current: Shared<'_, T>,
541
146
        new: P,
542
146
        success: Ordering,
543
146
        failure: Ordering,
544
146
        _: &'g Guard,
545
146
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
546
146
    where
547
146
        P: Pointer<T>,
548
146
    {
549
146
        let new = new.into_usize();
550
146
        self.data
551
146
            .compare_exchange_weak(current.into_usize(), new, success, failure)
552
146
            .map(|_| unsafe { Shared::from_usize(new) })
553
146
            .map_err(|current| unsafe {
554
                CompareExchangeError {
555
                    current: Shared::from_usize(current),
556
                    new: P::from_usize(new),
557
                }
558
146
            })
559
146
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::compare_exchange_weak::<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>
Line
Count
Source
538
10.3k
    pub fn compare_exchange_weak<'g, P>(
539
10.3k
        &self,
540
10.3k
        current: Shared<'_, T>,
541
10.3k
        new: P,
542
10.3k
        success: Ordering,
543
10.3k
        failure: Ordering,
544
10.3k
        _: &'g Guard,
545
10.3k
    ) -> Result<Shared<'g, T>, CompareExchangeError<'g, T, P>>
546
10.3k
    where
547
10.3k
        P: Pointer<T>,
548
10.3k
    {
549
10.3k
        let new = new.into_usize();
550
10.3k
        self.data
551
10.3k
            .compare_exchange_weak(current.into_usize(), new, success, failure)
552
10.3k
            .map(|_| unsafe { Shared::from_usize(new) })
553
10.3k
            .map_err(|current| unsafe {
554
                CompareExchangeError {
555
                    current: Shared::from_usize(current),
556
                    new: P::from_usize(new),
557
                }
558
10.3k
            })
559
10.3k
    }
560
561
    /// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current
562
    /// value is the same as `current`. The tag is also taken into account, so two pointers to the
563
    /// same object, but with different tags, will not be considered equal.
564
    ///
565
    /// The return value is a result indicating whether the new pointer was written. On success the
566
    /// pointer that was written is returned. On failure the actual current value and `new` are
567
    /// returned.
568
    ///
569
    /// This method takes a [`CompareAndSetOrdering`] argument which describes the memory
570
    /// ordering of this operation.
571
    ///
572
    /// # Migrating to `compare_exchange`
573
    ///
574
    /// `compare_and_set` is equivalent to `compare_exchange` with the following mapping for
575
    /// memory orderings:
576
    ///
577
    /// Original | Success | Failure
578
    /// -------- | ------- | -------
579
    /// Relaxed  | Relaxed | Relaxed
580
    /// Acquire  | Acquire | Acquire
581
    /// Release  | Release | Relaxed
582
    /// AcqRel   | AcqRel  | Acquire
583
    /// SeqCst   | SeqCst  | SeqCst
584
    ///
585
    /// # Examples
586
    ///
587
    /// ```
588
    /// # #![allow(deprecated)]
589
    /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared};
590
    /// use std::sync::atomic::Ordering::SeqCst;
591
    ///
592
    /// let a = Atomic::new(1234);
593
    ///
594
    /// let guard = &epoch::pin();
595
    /// let curr = a.load(SeqCst, guard);
596
    /// let res1 = a.compare_and_set(curr, Shared::null(), SeqCst, guard);
597
    /// let res2 = a.compare_and_set(curr, Owned::new(5678), SeqCst, guard);
598
    /// ```
599
    // TODO: remove in the next major version.
600
    #[allow(deprecated)]
601
    #[deprecated(note = "Use `compare_exchange` instead")]
602
0
    pub fn compare_and_set<'g, O, P>(
603
0
        &self,
604
0
        current: Shared<'_, T>,
605
0
        new: P,
606
0
        ord: O,
607
0
        guard: &'g Guard,
608
0
    ) -> Result<Shared<'g, T>, CompareAndSetError<'g, T, P>>
609
0
    where
610
0
        O: CompareAndSetOrdering,
611
0
        P: Pointer<T>,
612
0
    {
613
0
        self.compare_exchange(current, new, ord.success(), ord.failure(), guard)
614
0
    }
615
616
    /// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current
617
    /// value is the same as `current`. The tag is also taken into account, so two pointers to the
618
    /// same object, but with different tags, will not be considered equal.
619
    ///
620
    /// Unlike [`compare_and_set`], this method is allowed to spuriously fail even when comparison
621
    /// succeeds, which can result in more efficient code on some platforms.  The return value is a
622
    /// result indicating whether the new pointer was written. On success the pointer that was
623
    /// written is returned. On failure the actual current value and `new` are returned.
624
    ///
625
    /// This method takes a [`CompareAndSetOrdering`] argument which describes the memory
626
    /// ordering of this operation.
627
    ///
628
    /// [`compare_and_set`]: Atomic::compare_and_set
629
    ///
630
    /// # Migrating to `compare_exchange_weak`
631
    ///
632
    /// `compare_and_set_weak` is equivalent to `compare_exchange_weak` with the following mapping for
633
    /// memory orderings:
634
    ///
635
    /// Original | Success | Failure
636
    /// -------- | ------- | -------
637
    /// Relaxed  | Relaxed | Relaxed
638
    /// Acquire  | Acquire | Acquire
639
    /// Release  | Release | Relaxed
640
    /// AcqRel   | AcqRel  | Acquire
641
    /// SeqCst   | SeqCst  | SeqCst
642
    ///
643
    /// # Examples
644
    ///
645
    /// ```
646
    /// # #![allow(deprecated)]
647
    /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared};
648
    /// use std::sync::atomic::Ordering::SeqCst;
649
    ///
650
    /// let a = Atomic::new(1234);
651
    /// let guard = &epoch::pin();
652
    ///
653
    /// let mut new = Owned::new(5678);
654
    /// let mut ptr = a.load(SeqCst, guard);
655
    /// loop {
656
    ///     match a.compare_and_set_weak(ptr, new, SeqCst, guard) {
657
    ///         Ok(p) => {
658
    ///             ptr = p;
659
    ///             break;
660
    ///         }
661
    ///         Err(err) => {
662
    ///             ptr = err.current;
663
    ///             new = err.new;
664
    ///         }
665
    ///     }
666
    /// }
667
    ///
668
    /// let mut curr = a.load(SeqCst, guard);
669
    /// loop {
670
    ///     match a.compare_and_set_weak(curr, Shared::null(), SeqCst, guard) {
671
    ///         Ok(_) => break,
672
    ///         Err(err) => curr = err.current,
673
    ///     }
674
    /// }
675
    /// ```
676
    // TODO: remove in the next major version.
677
    #[allow(deprecated)]
678
    #[deprecated(note = "Use `compare_exchange_weak` instead")]
679
0
    pub fn compare_and_set_weak<'g, O, P>(
680
0
        &self,
681
0
        current: Shared<'_, T>,
682
0
        new: P,
683
0
        ord: O,
684
0
        guard: &'g Guard,
685
0
    ) -> Result<Shared<'g, T>, CompareAndSetError<'g, T, P>>
686
0
    where
687
0
        O: CompareAndSetOrdering,
688
0
        P: Pointer<T>,
689
0
    {
690
0
        self.compare_exchange_weak(current, new, ord.success(), ord.failure(), guard)
691
0
    }
692
693
    /// Bitwise "and" with the current tag.
694
    ///
695
    /// Performs a bitwise "and" operation on the current tag and the argument `val`, and sets the
696
    /// new tag to the result. Returns the previous pointer.
697
    ///
698
    /// This method takes an [`Ordering`] argument which describes the memory ordering of this
699
    /// operation.
700
    ///
701
    /// # Examples
702
    ///
703
    /// ```
704
    /// use crossbeam_epoch::{self as epoch, Atomic, Shared};
705
    /// use std::sync::atomic::Ordering::SeqCst;
706
    ///
707
    /// let a = Atomic::<i32>::from(Shared::null().with_tag(3));
708
    /// let guard = &epoch::pin();
709
    /// assert_eq!(a.fetch_and(2, SeqCst, guard).tag(), 3);
710
    /// assert_eq!(a.load(SeqCst, guard).tag(), 2);
711
    /// ```
712
0
    pub fn fetch_and<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
713
0
        unsafe { Shared::from_usize(self.data.fetch_and(val | !low_bits::<T>(), ord)) }
714
0
    }
715
716
    /// Bitwise "or" with the current tag.
717
    ///
718
    /// Performs a bitwise "or" operation on the current tag and the argument `val`, and sets the
719
    /// new tag to the result. Returns the previous pointer.
720
    ///
721
    /// This method takes an [`Ordering`] argument which describes the memory ordering of this
722
    /// operation.
723
    ///
724
    /// # Examples
725
    ///
726
    /// ```
727
    /// use crossbeam_epoch::{self as epoch, Atomic, Shared};
728
    /// use std::sync::atomic::Ordering::SeqCst;
729
    ///
730
    /// let a = Atomic::<i32>::from(Shared::null().with_tag(1));
731
    /// let guard = &epoch::pin();
732
    /// assert_eq!(a.fetch_or(2, SeqCst, guard).tag(), 1);
733
    /// assert_eq!(a.load(SeqCst, guard).tag(), 3);
734
    /// ```
735
7.69k
    pub fn fetch_or<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
736
7.69k
        unsafe { Shared::from_usize(self.data.fetch_or(val & low_bits::<T>(), ord)) }
737
7.69k
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::fetch_or
Line
Count
Source
735
5
    pub fn fetch_or<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
736
5
        unsafe { Shared::from_usize(self.data.fetch_or(val & low_bits::<T>(), ord)) }
737
5
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::fetch_or
Line
Count
Source
735
146
    pub fn fetch_or<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
736
146
        unsafe { Shared::from_usize(self.data.fetch_or(val & low_bits::<T>(), ord)) }
737
146
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::fetch_or
Line
Count
Source
735
1
    pub fn fetch_or<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
736
1
        unsafe { Shared::from_usize(self.data.fetch_or(val & low_bits::<T>(), ord)) }
737
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>>>::fetch_or
Line
Count
Source
735
55
    pub fn fetch_or<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
736
55
        unsafe { Shared::from_usize(self.data.fetch_or(val & low_bits::<T>(), ord)) }
737
55
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_epoch::sync::list::Entry>>::fetch_or
Line
Count
Source
735
7.48k
    pub fn fetch_or<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
736
7.48k
        unsafe { Shared::from_usize(self.data.fetch_or(val & low_bits::<T>(), ord)) }
737
7.48k
    }
738
739
    /// Bitwise "xor" with the current tag.
740
    ///
741
    /// Performs a bitwise "xor" operation on the current tag and the argument `val`, and sets the
742
    /// new tag to the result. Returns the previous pointer.
743
    ///
744
    /// This method takes an [`Ordering`] argument which describes the memory ordering of this
745
    /// operation.
746
    ///
747
    /// # Examples
748
    ///
749
    /// ```
750
    /// use crossbeam_epoch::{self as epoch, Atomic, Shared};
751
    /// use std::sync::atomic::Ordering::SeqCst;
752
    ///
753
    /// let a = Atomic::<i32>::from(Shared::null().with_tag(1));
754
    /// let guard = &epoch::pin();
755
    /// assert_eq!(a.fetch_xor(3, SeqCst, guard).tag(), 1);
756
    /// assert_eq!(a.load(SeqCst, guard).tag(), 2);
757
    /// ```
758
0
    pub fn fetch_xor<'g>(&self, val: usize, ord: Ordering, _: &'g Guard) -> Shared<'g, T> {
759
0
        unsafe { Shared::from_usize(self.data.fetch_xor(val & low_bits::<T>(), ord)) }
760
0
    }
761
762
    /// Takes ownership of the pointee.
763
    ///
764
    /// This consumes the atomic and converts it into [`Owned`]. As [`Atomic`] doesn't have a
765
    /// destructor and doesn't drop the pointee while [`Owned`] does, this is suitable for
766
    /// destructors of data structures.
767
    ///
768
    /// # Panics
769
    ///
770
    /// Panics if this pointer is null, but only in debug mode.
771
    ///
772
    /// # Safety
773
    ///
774
    /// This method may be called only if the pointer is valid and nobody else is holding a
775
    /// reference to the same object.
776
    ///
777
    /// # Examples
778
    ///
779
    /// ```rust
780
    /// # use std::mem;
781
    /// # use crossbeam_epoch::Atomic;
782
    /// struct DataStructure {
783
    ///     ptr: Atomic<usize>,
784
    /// }
785
    ///
786
    /// impl Drop for DataStructure {
787
    ///     fn drop(&mut self) {
788
    ///         // By now the DataStructure lives only in our thread and we are sure we don't hold
789
    ///         // any Shared or & to it ourselves.
790
    ///         unsafe {
791
    ///             drop(mem::replace(&mut self.ptr, Atomic::null()).into_owned());
792
    ///         }
793
    ///     }
794
    /// }
795
    /// ```
796
0
    pub unsafe fn into_owned(self) -> Owned<T> {
797
0
        #[cfg(loom_crossbeam)]
798
0
        {
799
0
            // FIXME: loom does not yet support into_inner, so we use unsync_load for now,
800
0
            // which should have the same synchronization properties:
801
0
            // https://github.com/tokio-rs/loom/issues/117
802
0
            Owned::from_usize(self.data.unsync_load())
803
0
        }
804
0
        #[cfg(not(loom_crossbeam))]
805
0
        {
806
0
            Owned::from_usize(self.data.into_inner())
807
0
        }
808
0
    }
809
}
810
811
impl<T: ?Sized + Pointable> fmt::Debug for Atomic<T> {
812
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
813
0
        let data = self.data.load(Ordering::SeqCst);
814
0
        let (raw, tag) = decompose_tag::<T>(data);
815
0
816
0
        f.debug_struct("Atomic")
817
0
            .field("raw", &raw)
818
0
            .field("tag", &tag)
819
0
            .finish()
820
0
    }
821
}
822
823
impl<T: ?Sized + Pointable> fmt::Pointer for Atomic<T> {
824
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
825
0
        let data = self.data.load(Ordering::SeqCst);
826
0
        let (raw, _) = decompose_tag::<T>(data);
827
0
        fmt::Pointer::fmt(&(unsafe { T::deref(raw) as *const _ }), f)
828
0
    }
829
}
830
831
impl<T: ?Sized + Pointable> Clone for Atomic<T> {
832
    /// Returns a copy of the atomic value.
833
    ///
834
    /// Note that a `Relaxed` load is used here. If you need synchronization, use it with other
835
    /// atomics or fences.
836
0
    fn clone(&self) -> Self {
837
0
        let data = self.data.load(Ordering::Relaxed);
838
0
        Atomic::from_usize(data)
839
0
    }
840
}
841
842
impl<T: ?Sized + Pointable> Default for Atomic<T> {
843
709
    fn default() -> Self {
844
709
        Atomic::null()
845
709
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>> as core::default::Default>::default
Line
Count
Source
843
67
    fn default() -> Self {
844
67
        Atomic::null()
845
67
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, ()>> as core::default::Default>::default
Line
Count
Source
843
32
    fn default() -> Self {
844
32
        Atomic::null()
845
32
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<alloc::string::String, alloc::boxed::Box<i32>>> as core::default::Default>::default
Line
Count
Source
843
32
    fn default() -> Self {
844
32
        Atomic::null()
845
32
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<i32, i32>> as core::default::Default>::default
Line
Count
Source
843
546
    fn default() -> Self {
844
546
        Atomic::null()
845
546
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>> as core::default::Default>::default
Line
Count
Source
843
32
    fn default() -> Self {
844
32
        Atomic::null()
845
32
    }
846
}
847
848
impl<T: ?Sized + Pointable> From<Owned<T>> for Atomic<T> {
849
    /// Returns a new atomic pointer pointing to `owned`.
850
    ///
851
    /// # Examples
852
    ///
853
    /// ```
854
    /// use crossbeam_epoch::{Atomic, Owned};
855
    ///
856
    /// let a = Atomic::<i32>::from(Owned::new(1234));
857
    /// ```
858
107
    fn from(owned: Owned<T>) -> Self {
859
107
        let data = owned.data;
860
107
        mem::forget(owned);
861
107
        Self::from_usize(data)
862
107
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<injector::destructors::Elem>> as core::convert::From<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>>>::from
Line
Count
Source
858
7
    fn from(owned: Owned<T>) -> Self {
859
7
        let data = owned.data;
860
7
        mem::forget(owned);
861
7
        Self::from_usize(data)
862
7
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>> as core::convert::From<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>>::from
Line
Count
Source
858
16
    fn from(owned: Owned<T>) -> Self {
859
16
        let data = owned.data;
860
16
        mem::forget(owned);
861
16
        Self::from_usize(data)
862
16
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>> as core::convert::From<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>>>>::from
Line
Count
Source
858
1
    fn from(owned: Owned<T>) -> Self {
859
1
        let data = owned.data;
860
1
        mem::forget(owned);
861
1
        Self::from_usize(data)
862
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>> as core::convert::From<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>>::from
Line
Count
Source
858
19
    fn from(owned: Owned<T>) -> Self {
859
19
        let data = owned.data;
860
19
        mem::forget(owned);
861
19
        Self::from_usize(data)
862
19
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>> as core::convert::From<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>>::from
Line
Count
Source
858
1
    fn from(owned: Owned<T>) -> Self {
859
1
        let data = owned.data;
860
1
        mem::forget(owned);
861
1
        Self::from_usize(data)
862
1
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>> as core::convert::From<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>>>>::from
Line
Count
Source
858
2
    fn from(owned: Owned<T>) -> Self {
859
2
        let data = owned.data;
860
2
        mem::forget(owned);
861
2
        Self::from_usize(data)
862
2
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>> as core::convert::From<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>>::from
Line
Count
Source
858
9
    fn from(owned: Owned<T>) -> Self {
859
9
        let data = owned.data;
860
9
        mem::forget(owned);
861
9
        Self::from_usize(data)
862
9
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>> as core::convert::From<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>>>>::from
Line
Count
Source
858
22
    fn from(owned: Owned<T>) -> Self {
859
22
        let data = owned.data;
860
22
        mem::forget(owned);
861
22
        Self::from_usize(data)
862
22
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<usize>> as core::convert::From<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>>::from
Line
Count
Source
858
18
    fn from(owned: Owned<T>) -> Self {
859
18
        let data = owned.data;
860
18
        mem::forget(owned);
861
18
        Self::from_usize(data)
862
18
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>> as core::convert::From<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>>::from
Line
Count
Source
858
9
    fn from(owned: Owned<T>) -> Self {
859
9
        let data = owned.data;
860
9
        mem::forget(owned);
861
9
        Self::from_usize(data)
862
9
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<i32>> as core::convert::From<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>>>>::from
Line
Count
Source
858
2
    fn from(owned: Owned<T>) -> Self {
859
2
        let data = owned.data;
860
2
        mem::forget(owned);
861
2
        Self::from_usize(data)
862
2
    }
<crossbeam_epoch::atomic::Atomic<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>> as core::convert::From<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>>::from
Line
Count
Source
858
1
    fn from(owned: Owned<T>) -> Self {
859
1
        let data = owned.data;
860
1
        mem::forget(owned);
861
1
        Self::from_usize(data)
862
1
    }
863
}
864
865
impl<T> From<Box<T>> for Atomic<T> {
866
0
    fn from(b: Box<T>) -> Self {
867
0
        Self::from(Owned::from(b))
868
0
    }
869
}
870
871
impl<T> From<T> for Atomic<T> {
872
0
    fn from(t: T) -> Self {
873
0
        Self::new(t)
874
0
    }
875
}
876
877
impl<'g, T: ?Sized + Pointable> From<Shared<'g, T>> for Atomic<T> {
878
    /// Returns a new atomic pointer pointing to `ptr`.
879
    ///
880
    /// # Examples
881
    ///
882
    /// ```
883
    /// use crossbeam_epoch::{Atomic, Shared};
884
    ///
885
    /// let a = Atomic::<i32>::from(Shared::<i32>::null());
886
    /// ```
887
0
    fn from(ptr: Shared<'g, T>) -> Self {
888
0
        Self::from_usize(ptr.data)
889
0
    }
890
}
891
892
impl<T> From<*const T> for Atomic<T> {
893
    /// Returns a new atomic pointer pointing to `raw`.
894
    ///
895
    /// # Examples
896
    ///
897
    /// ```
898
    /// use std::ptr;
899
    /// use crossbeam_epoch::Atomic;
900
    ///
901
    /// let a = Atomic::<i32>::from(ptr::null::<i32>());
902
    /// ```
903
0
    fn from(raw: *const T) -> Self {
904
0
        Self::from_usize(raw as usize)
905
0
    }
906
}
907
908
/// A trait for either `Owned` or `Shared` pointers.
909
pub trait Pointer<T: ?Sized + Pointable> {
910
    /// Returns the machine representation of the pointer.
911
    fn into_usize(self) -> usize;
912
913
    /// Returns a new pointer pointing to the tagged pointer `data`.
914
    ///
915
    /// # Safety
916
    ///
917
    /// The given `data` should have been created by `Pointer::into_usize()`, and one `data` should
918
    /// not be converted back by `Pointer::from_usize()` multiple times.
919
    unsafe fn from_usize(data: usize) -> Self;
920
}
921
922
/// An owned heap-allocated object.
923
///
924
/// This type is very similar to `Box<T>`.
925
///
926
/// The pointer must be properly aligned. Since it is aligned, a tag can be stored into the unused
927
/// least significant bits of the address.
928
pub struct Owned<T: ?Sized + Pointable> {
929
    data: usize,
930
    _marker: PhantomData<Box<T>>,
931
}
932
933
impl<T: ?Sized + Pointable> Pointer<T> for Owned<T> {
934
    #[inline]
935
4.01M
    fn into_usize(self) -> usize {
936
4.01M
        let data = self.data;
937
4.01M
        mem::forget(self);
938
4.01M
        data
939
4.01M
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::internal::Local> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::internal::Local>>::into_usize
Line
Count
Source
935
146
    fn into_usize(self) -> usize {
936
146
        let data = self.data;
937
146
        mem::forget(self);
938
146
        data
939
146
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::into_usize
Line
Count
Source
935
260
    fn into_usize(self) -> usize {
936
260
        let data = self.data;
937
260
        mem::forget(self);
938
260
        data
939
260
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<usize>>>::into_usize
Line
Count
Source
935
16
    fn into_usize(self) -> usize {
936
16
        let data = self.data;
937
16
        mem::forget(self);
938
16
        data
939
16
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::into_usize
Line
Count
Source
935
10
    fn into_usize(self) -> usize {
936
10
        let data = self.data;
937
10
        mem::forget(self);
938
10
        data
939
10
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::into_usize
Line
Count
Source
935
15
    fn into_usize(self) -> usize {
936
15
        let data = self.data;
937
15
        mem::forget(self);
938
15
        data
939
15
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::into_usize
Line
Count
Source
935
11
    fn into_usize(self) -> usize {
936
11
        let data = self.data;
937
11
        mem::forget(self);
938
11
        data
939
11
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<usize>>>::into_usize
Line
Count
Source
935
10
    fn into_usize(self) -> usize {
936
10
        let data = self.data;
937
10
        mem::forget(self);
938
10
        data
939
10
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::into_usize
Line
Count
Source
935
10
    fn into_usize(self) -> usize {
936
10
        let data = self.data;
937
10
        mem::forget(self);
938
10
        data
939
10
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::list::Entry> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::list::Entry>>::into_usize
Line
Count
Source
935
8.10k
    fn into_usize(self) -> usize {
936
8.10k
        let data = self.data;
937
8.10k
        mem::forget(self);
938
8.10k
        data
939
8.10k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::collector::tests::stress::Elem> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::collector::tests::stress::Elem>>::into_usize
Line
Count
Source
935
753k
    fn into_usize(self) -> usize {
936
753k
        let data = self.data;
937
753k
        mem::forget(self);
938
753k
        data
939
753k
    }
<crossbeam_epoch::atomic::Owned<i32> as crossbeam_epoch::atomic::Pointer<i32>>::into_usize
Line
Count
Source
935
196k
    fn into_usize(self) -> usize {
936
196k
        let data = self.data;
937
196k
        mem::forget(self);
938
196k
        data
939
196k
    }
<crossbeam_epoch::atomic::Owned<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>> as crossbeam_epoch::atomic::Pointer<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>>>::into_usize
Line
Count
Source
935
1
    fn into_usize(self) -> usize {
936
1
        let data = self.data;
937
1
        mem::forget(self);
938
1
        data
939
1
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::into_usize
Line
Count
Source
935
5
    fn into_usize(self) -> usize {
936
5
        let data = self.data;
937
5
        mem::forget(self);
938
5
        data
939
5
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::internal::Local> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::internal::Local>>::into_usize
Line
Count
Source
935
70
    fn into_usize(self) -> usize {
936
70
        let data = self.data;
937
70
        mem::forget(self);
938
70
        data
939
70
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<i64>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<i64>>>::into_usize
Line
Count
Source
935
2.89M
    fn into_usize(self) -> usize {
936
2.89M
        let data = self.data;
937
2.89M
        mem::forget(self);
938
2.89M
        data
939
2.89M
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::into_usize
Line
Count
Source
935
64.9k
    fn into_usize(self) -> usize {
936
64.9k
        let data = self.data;
937
64.9k
        mem::forget(self);
938
64.9k
        data
939
64.9k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::collector::tests::count_drops::Elem> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::collector::tests::count_drops::Elem>>::into_usize
Line
Count
Source
935
100k
    fn into_usize(self) -> usize {
936
100k
        let data = self.data;
937
100k
        mem::forget(self);
938
100k
        data
939
100k
    }
940
941
    /// Returns a new pointer pointing to the tagged pointer `data`.
942
    ///
943
    /// # Panics
944
    ///
945
    /// Panics if the data is zero in debug mode.
946
    #[inline]
947
7.58M
    unsafe fn from_usize(data: usize) -> Self {
948
7.69M
        debug_assert!(data != 0, "converting zero into `Owned`");
949
7.67M
        Owned {
950
7.67M
            data,
951
7.67M
            _marker: PhantomData,
952
7.67M
        }
953
7.67M
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::from_usize
Line
Count
Source
947
395
    unsafe fn from_usize(data: usize) -> Self {
948
395
        debug_assert!(data != 0, "converting zero into `Owned`");
949
395
        Owned {
950
395
            data,
951
395
            _marker: PhantomData,
952
395
        }
953
395
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::internal::Local> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::internal::Local>>::from_usize
Line
Count
Source
947
216
    unsafe fn from_usize(data: usize) -> Self {
948
216
        debug_assert!(data != 0, "converting zero into `Owned`");
949
216
        Owned {
950
216
            data,
951
216
            _marker: PhantomData,
952
216
        }
953
216
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<usize>>>::from_usize
Line
Count
Source
947
28
    unsafe fn from_usize(data: usize) -> Self {
948
29
        debug_assert!(data != 0, "converting zero into `Owned`");
949
28
        Owned {
950
28
            data,
951
28
            _marker: PhantomData,
952
28
        }
953
28
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<injector::destructors::Elem>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>>::from_usize
Line
Count
Source
947
15
    unsafe fn from_usize(data: usize) -> Self {
948
15
        debug_assert!(data != 0, "converting zero into `Owned`");
949
15
        Owned {
950
15
            data,
951
15
            _marker: PhantomData,
952
15
        }
953
15
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<i32>>>::from_usize
Line
Count
Source
947
2
    unsafe fn from_usize(data: usize) -> Self {
948
2
        debug_assert!(data != 0, "converting zero into `Owned`");
949
2
        Owned {
950
2
            data,
951
2
            _marker: PhantomData,
952
2
        }
953
2
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<usize>>>::from_usize
Line
Count
Source
947
68
    unsafe fn from_usize(data: usize) -> Self {
948
68
        debug_assert!(data != 0, "converting zero into `Owned`");
949
68
        Owned {
950
68
            data,
951
68
            _marker: PhantomData,
952
68
        }
953
68
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::from_usize
Line
Count
Source
947
38
    unsafe fn from_usize(data: usize) -> Self {
948
38
        debug_assert!(data != 0, "converting zero into `Owned`");
949
38
        Owned {
950
38
            data,
951
38
            _marker: PhantomData,
952
38
        }
953
38
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::from_usize
Line
Count
Source
947
32
    unsafe fn from_usize(data: usize) -> Self {
948
32
        debug_assert!(data != 0, "converting zero into `Owned`");
949
32
        Owned {
950
32
            data,
951
32
            _marker: PhantomData,
952
32
        }
953
32
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<i32>>>::from_usize
Line
Count
Source
947
4
    unsafe fn from_usize(data: usize) -> Self {
948
4
        debug_assert!(data != 0, "converting zero into `Owned`");
949
4
        Owned {
950
4
            data,
951
4
            _marker: PhantomData,
952
4
        }
953
4
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<i32>>>::from_usize
Line
Count
Source
947
43
    unsafe fn from_usize(data: usize) -> Self {
948
44
        debug_assert!(data != 0, "converting zero into `Owned`");
949
43
        Owned {
950
43
            data,
951
43
            _marker: PhantomData,
952
43
        }
953
43
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<usize>>>::from_usize
Line
Count
Source
947
57
    unsafe fn from_usize(data: usize) -> Self {
948
56
        debug_assert!(data != 0, "converting zero into `Owned`");
949
57
        Owned {
950
57
            data,
951
57
            _marker: PhantomData,
952
57
        }
953
57
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::from_usize
Line
Count
Source
947
38
    unsafe fn from_usize(data: usize) -> Self {
948
38
        debug_assert!(data != 0, "converting zero into `Owned`");
949
38
        Owned {
950
38
            data,
951
38
            _marker: PhantomData,
952
38
        }
953
38
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<i32>>>::from_usize
Line
Count
Source
947
3
    unsafe fn from_usize(data: usize) -> Self {
948
4
        debug_assert!(data != 0, "converting zero into `Owned`");
949
3
        Owned {
950
3
            data,
951
3
            _marker: PhantomData,
952
3
        }
953
3
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::from_usize
Line
Count
Source
947
24
    unsafe fn from_usize(data: usize) -> Self {
948
24
        debug_assert!(data != 0, "converting zero into `Owned`");
949
24
        Owned {
950
24
            data,
951
24
            _marker: PhantomData,
952
24
        }
953
24
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::from_usize
Line
Count
Source
947
129k
    unsafe fn from_usize(data: usize) -> Self {
948
129k
        debug_assert!(data != 0, "converting zero into `Owned`");
949
129k
        Owned {
950
129k
            data,
951
129k
            _marker: PhantomData,
952
129k
        }
953
129k
    }
<crossbeam_epoch::atomic::Owned<i32> as crossbeam_epoch::atomic::Pointer<i32>>::from_usize
Line
Count
Source
947
396k
    unsafe fn from_usize(data: usize) -> Self {
948
394k
        debug_assert!(data != 0, "converting zero into `Owned`");
949
397k
        Owned {
950
397k
            data,
951
397k
            _marker: PhantomData,
952
397k
        }
953
397k
    }
<crossbeam_epoch::atomic::Owned<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>> as crossbeam_epoch::atomic::Pointer<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>>>::from_usize
Line
Count
Source
947
2
    unsafe fn from_usize(data: usize) -> Self {
948
2
        debug_assert!(data != 0, "converting zero into `Owned`");
949
2
        Owned {
950
2
            data,
951
2
            _marker: PhantomData,
952
2
        }
953
2
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::from_usize
Line
Count
Source
947
10
    unsafe fn from_usize(data: usize) -> Self {
948
10
        debug_assert!(data != 0, "converting zero into `Owned`");
949
10
        Owned {
950
10
            data,
951
10
            _marker: PhantomData,
952
10
        }
953
10
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::list::Entry> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::list::Entry>>::from_usize
Line
Count
Source
947
16.3k
    unsafe fn from_usize(data: usize) -> Self {
948
16.3k
        debug_assert!(data != 0, "converting zero into `Owned`");
949
16.3k
        Owned {
950
16.3k
            data,
951
16.3k
            _marker: PhantomData,
952
16.3k
        }
953
16.3k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::collector::tests::stress::Elem> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::collector::tests::stress::Elem>>::from_usize
Line
Count
Source
947
1.30M
    unsafe fn from_usize(data: usize) -> Self {
948
1.44M
        debug_assert!(data != 0, "converting zero into `Owned`");
949
1.34M
        Owned {
950
1.34M
            data,
951
1.34M
            _marker: PhantomData,
952
1.34M
        }
953
1.34M
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::collector::tests::count_drops::Elem> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::collector::tests::count_drops::Elem>>::from_usize
Line
Count
Source
947
200k
    unsafe fn from_usize(data: usize) -> Self {
948
200k
        debug_assert!(data != 0, "converting zero into `Owned`");
949
200k
        Owned {
950
200k
            data,
951
200k
            _marker: PhantomData,
952
200k
        }
953
200k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::internal::Local> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::internal::Local>>::from_usize
Line
Count
Source
947
135
    unsafe fn from_usize(data: usize) -> Self {
948
135
        debug_assert!(data != 0, "converting zero into `Owned`");
949
135
        Owned {
950
135
            data,
951
135
            _marker: PhantomData,
952
135
        }
953
135
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<i64>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<i64>>>::from_usize
Line
Count
Source
947
5.53M
    unsafe fn from_usize(data: usize) -> Self {
948
5.50M
        debug_assert!(data != 0, "converting zero into `Owned`");
949
5.58M
        Owned {
950
5.58M
            data,
951
5.58M
            _marker: PhantomData,
952
5.58M
        }
953
5.58M
    }
954
}
955
956
impl<T> Owned<T> {
957
    /// Returns a new owned pointer pointing to `raw`.
958
    ///
959
    /// This function is unsafe because improper use may lead to memory problems. Argument `raw`
960
    /// must be a valid pointer. Also, a double-free may occur if the function is called twice on
961
    /// the same raw pointer.
962
    ///
963
    /// # Panics
964
    ///
965
    /// Panics if `raw` is not properly aligned.
966
    ///
967
    /// # Safety
968
    ///
969
    /// The given `raw` should have been derived from `Owned`, and one `raw` should not be converted
970
    /// back by `Owned::from_raw()` multiple times.
971
    ///
972
    /// # Examples
973
    ///
974
    /// ```
975
    /// use crossbeam_epoch::Owned;
976
    ///
977
    /// let o = unsafe { Owned::from_raw(Box::into_raw(Box::new(1234))) };
978
    /// ```
979
0
    pub unsafe fn from_raw(raw: *mut T) -> Owned<T> {
980
0
        let raw = raw as usize;
981
0
        ensure_aligned::<T>(raw);
982
0
        Self::from_usize(raw)
983
0
    }
984
985
    /// Converts the owned pointer into a `Box`.
986
    ///
987
    /// # Examples
988
    ///
989
    /// ```
990
    /// use crossbeam_epoch::Owned;
991
    ///
992
    /// let o = Owned::new(1234);
993
    /// let b: Box<i32> = o.into_box();
994
    /// assert_eq!(*b, 1234);
995
    /// ```
996
175
    pub fn into_box(self) -> Box<T> {
997
175
        let (raw, _) = decompose_tag::<T>(self.data);
998
175
        mem::forget(self);
999
175
        unsafe { Box::from_raw(raw as *mut _) }
1000
175
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>::into_box
Line
Count
Source
996
13
    pub fn into_box(self) -> Box<T> {
997
13
        let (raw, _) = decompose_tag::<T>(self.data);
998
13
        mem::forget(self);
999
13
        unsafe { Box::from_raw(raw as *mut _) }
1000
13
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>>::into_box
Line
Count
Source
996
8
    pub fn into_box(self) -> Box<T> {
997
8
        let (raw, _) = decompose_tag::<T>(self.data);
998
8
        mem::forget(self);
999
8
        unsafe { Box::from_raw(raw as *mut _) }
1000
8
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>>>::into_box
Line
Count
Source
996
1
    pub fn into_box(self) -> Box<T> {
997
1
        let (raw, _) = decompose_tag::<T>(self.data);
998
1
        mem::forget(self);
999
1
        unsafe { Box::from_raw(raw as *mut _) }
1000
1
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>::into_box
Line
Count
Source
996
33
    pub fn into_box(self) -> Box<T> {
997
33
        let (raw, _) = decompose_tag::<T>(self.data);
998
33
        mem::forget(self);
999
33
        unsafe { Box::from_raw(raw as *mut _) }
1000
33
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::into_box
Line
Count
Source
996
19
    pub fn into_box(self) -> Box<T> {
997
19
        let (raw, _) = decompose_tag::<T>(self.data);
998
19
        mem::forget(self);
999
19
        unsafe { Box::from_raw(raw as *mut _) }
1000
19
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::into_box
Line
Count
Source
996
16
    pub fn into_box(self) -> Box<T> {
997
16
        let (raw, _) = decompose_tag::<T>(self.data);
998
16
        mem::forget(self);
999
16
        unsafe { Box::from_raw(raw as *mut _) }
1000
16
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>>>::into_box
Line
Count
Source
996
2
    pub fn into_box(self) -> Box<T> {
997
2
        let (raw, _) = decompose_tag::<T>(self.data);
998
2
        mem::forget(self);
999
2
        unsafe { Box::from_raw(raw as *mut _) }
1000
2
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>>>::into_box
Line
Count
Source
996
22
    pub fn into_box(self) -> Box<T> {
997
22
        let (raw, _) = decompose_tag::<T>(self.data);
998
22
        mem::forget(self);
999
22
        unsafe { Box::from_raw(raw as *mut _) }
1000
22
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>::into_box
Line
Count
Source
996
28
    pub fn into_box(self) -> Box<T> {
997
28
        let (raw, _) = decompose_tag::<T>(self.data);
998
28
        mem::forget(self);
999
28
        unsafe { Box::from_raw(raw as *mut _) }
1000
28
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::into_box
Line
Count
Source
996
19
    pub fn into_box(self) -> Box<T> {
997
19
        let (raw, _) = decompose_tag::<T>(self.data);
998
19
        mem::forget(self);
999
19
        unsafe { Box::from_raw(raw as *mut _) }
1000
19
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>>>::into_box
Line
Count
Source
996
2
    pub fn into_box(self) -> Box<T> {
997
2
        let (raw, _) = decompose_tag::<T>(self.data);
998
2
        mem::forget(self);
999
2
        unsafe { Box::from_raw(raw as *mut _) }
1000
2
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::into_box
Line
Count
Source
996
12
    pub fn into_box(self) -> Box<T> {
997
12
        let (raw, _) = decompose_tag::<T>(self.data);
998
12
        mem::forget(self);
999
12
        unsafe { Box::from_raw(raw as *mut _) }
1000
12
    }
1001
1002
    /// Allocates `value` on the heap and returns a new owned pointer pointing to it.
1003
    ///
1004
    /// # Examples
1005
    ///
1006
    /// ```
1007
    /// use crossbeam_epoch::Owned;
1008
    ///
1009
    /// let o = Owned::new(1234);
1010
    /// ```
1011
3.92M
    pub fn new(init: T) -> Owned<T> {
1012
3.92M
        Self::init(init)
1013
3.92M
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::internal::Local>>::new
Line
Count
Source
1011
146
    pub fn new(init: T) -> Owned<T> {
1012
146
        Self::init(init)
1013
146
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::new
Line
Count
Source
1011
262
    pub fn new(init: T) -> Owned<T> {
1012
262
        Self::init(init)
1013
262
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::new
Line
Count
Source
1011
15
    pub fn new(init: T) -> Owned<T> {
1012
15
        Self::init(init)
1013
15
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::new
Line
Count
Source
1011
10
    pub fn new(init: T) -> Owned<T> {
1012
10
        Self::init(init)
1013
10
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>::new
Line
Count
Source
1011
16
    pub fn new(init: T) -> Owned<T> {
1012
16
        Self::init(init)
1013
16
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::new
Line
Count
Source
1011
10
    pub fn new(init: T) -> Owned<T> {
1012
10
        Self::init(init)
1013
10
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>::new
Line
Count
Source
1011
10
    pub fn new(init: T) -> Owned<T> {
1012
10
        Self::init(init)
1013
10
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::new
Line
Count
Source
1011
11
    pub fn new(init: T) -> Owned<T> {
1012
11
        Self::init(init)
1013
11
    }
<crossbeam_epoch::atomic::Owned<i32>>::new
Line
Count
Source
1011
196k
    pub fn new(init: T) -> Owned<T> {
1012
196k
        Self::init(init)
1013
196k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::list::Entry>>::new
Line
Count
Source
1011
8.17k
    pub fn new(init: T) -> Owned<T> {
1012
8.17k
        Self::init(init)
1013
8.17k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::collector::tests::stress::Elem>>::new
Line
Count
Source
1011
722k
    pub fn new(init: T) -> Owned<T> {
1012
722k
        Self::init(init)
1013
722k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::internal::Local>>::new
Line
Count
Source
1011
67
    pub fn new(init: T) -> Owned<T> {
1012
67
        Self::init(init)
1013
67
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::collector::tests::count_drops::Elem>>::new
Line
Count
Source
1011
100k
    pub fn new(init: T) -> Owned<T> {
1012
100k
        Self::init(init)
1013
100k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::new
Line
Count
Source
1011
64.8k
    pub fn new(init: T) -> Owned<T> {
1012
64.8k
        Self::init(init)
1013
64.8k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<i64>>>::new
Line
Count
Source
1011
2.83M
    pub fn new(init: T) -> Owned<T> {
1012
2.83M
        Self::init(init)
1013
2.83M
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::new
Line
Count
Source
1011
5
    pub fn new(init: T) -> Owned<T> {
1012
5
        Self::init(init)
1013
5
    }
<crossbeam_epoch::atomic::Owned<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>>>::new
Line
Count
Source
1011
1
    pub fn new(init: T) -> Owned<T> {
1012
1
        Self::init(init)
1013
1
    }
1014
}
1015
1016
impl<T: ?Sized + Pointable> Owned<T> {
1017
    /// Allocates `value` on the heap and returns a new owned pointer pointing to it.
1018
    ///
1019
    /// # Examples
1020
    ///
1021
    /// ```
1022
    /// use crossbeam_epoch::Owned;
1023
    ///
1024
    /// let o = Owned::<i32>::init(1234);
1025
    /// ```
1026
3.94M
    pub fn init(init: T::Init) -> Owned<T> {
1027
3.94M
        unsafe { Self::from_usize(T::init(init)) }
1028
3.94M
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::init
Line
Count
Source
1026
263
    pub fn init(init: T::Init) -> Owned<T> {
1027
263
        unsafe { Self::from_usize(T::init(init)) }
1028
263
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::internal::Local>>::init
Line
Count
Source
1026
146
    pub fn init(init: T::Init) -> Owned<T> {
1027
146
        unsafe { Self::from_usize(T::init(init)) }
1028
146
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>::init
Line
Count
Source
1026
16
    pub fn init(init: T::Init) -> Owned<T> {
1027
16
        unsafe { Self::from_usize(T::init(init)) }
1028
16
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>>::init
Line
Count
Source
1026
7
    pub fn init(init: T::Init) -> Owned<T> {
1027
7
        unsafe { Self::from_usize(T::init(init)) }
1028
7
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>>>::init
Line
Count
Source
1026
1
    pub fn init(init: T::Init) -> Owned<T> {
1027
1
        unsafe { Self::from_usize(T::init(init)) }
1028
1
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>::init
Line
Count
Source
1026
34
    pub fn init(init: T::Init) -> Owned<T> {
1027
34
        unsafe { Self::from_usize(T::init(init)) }
1028
34
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::init
Line
Count
Source
1026
16
    pub fn init(init: T::Init) -> Owned<T> {
1027
16
        unsafe { Self::from_usize(T::init(init)) }
1028
16
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>>>::init
Line
Count
Source
1026
2
    pub fn init(init: T::Init) -> Owned<T> {
1027
2
        unsafe { Self::from_usize(T::init(init)) }
1028
2
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::init
Line
Count
Source
1026
19
    pub fn init(init: T::Init) -> Owned<T> {
1027
19
        unsafe { Self::from_usize(T::init(init)) }
1028
19
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>>>::init
Line
Count
Source
1026
21
    pub fn init(init: T::Init) -> Owned<T> {
1027
21
        unsafe { Self::from_usize(T::init(init)) }
1028
21
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>::init
Line
Count
Source
1026
28
    pub fn init(init: T::Init) -> Owned<T> {
1027
28
        unsafe { Self::from_usize(T::init(init)) }
1028
28
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::init
Line
Count
Source
1026
19
    pub fn init(init: T::Init) -> Owned<T> {
1027
19
        unsafe { Self::from_usize(T::init(init)) }
1028
19
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<i32>>>::init
Line
Count
Source
1026
2
    pub fn init(init: T::Init) -> Owned<T> {
1027
2
        unsafe { Self::from_usize(T::init(init)) }
1028
2
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::init
Line
Count
Source
1026
12
    pub fn init(init: T::Init) -> Owned<T> {
1027
12
        unsafe { Self::from_usize(T::init(init)) }
1028
12
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::list::Entry>>::init
Line
Count
Source
1026
8.15k
    pub fn init(init: T::Init) -> Owned<T> {
1027
8.15k
        unsafe { Self::from_usize(T::init(init)) }
1028
8.15k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::collector::tests::stress::Elem>>::init
Line
Count
Source
1026
742k
    pub fn init(init: T::Init) -> Owned<T> {
1027
742k
        unsafe { Self::from_usize(T::init(init)) }
1028
742k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::init
Line
Count
Source
1026
5
    pub fn init(init: T::Init) -> Owned<T> {
1027
5
        unsafe { Self::from_usize(T::init(init)) }
1028
5
    }
<crossbeam_epoch::atomic::Owned<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>>>::init
Line
Count
Source
1026
1
    pub fn init(init: T::Init) -> Owned<T> {
1027
1
        unsafe { Self::from_usize(T::init(init)) }
1028
1
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::internal::Local>>::init
Line
Count
Source
1026
67
    pub fn init(init: T::Init) -> Owned<T> {
1027
67
        unsafe { Self::from_usize(T::init(init)) }
1028
67
    }
<crossbeam_epoch::atomic::Owned<i32>>::init
Line
Count
Source
1026
191k
    pub fn init(init: T::Init) -> Owned<T> {
1027
191k
        unsafe { Self::from_usize(T::init(init)) }
1028
191k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::init
Line
Count
Source
1026
64.9k
    pub fn init(init: T::Init) -> Owned<T> {
1027
64.9k
        unsafe { Self::from_usize(T::init(init)) }
1028
64.9k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<i64>>>::init
Line
Count
Source
1026
2.83M
    pub fn init(init: T::Init) -> Owned<T> {
1027
2.83M
        unsafe { Self::from_usize(T::init(init)) }
1028
2.83M
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::collector::tests::count_drops::Elem>>::init
Line
Count
Source
1026
100k
    pub fn init(init: T::Init) -> Owned<T> {
1027
100k
        unsafe { Self::from_usize(T::init(init)) }
1028
100k
    }
1029
1030
    /// Converts the owned pointer into a [`Shared`].
1031
    ///
1032
    /// # Examples
1033
    ///
1034
    /// ```
1035
    /// use crossbeam_epoch::{self as epoch, Owned};
1036
    ///
1037
    /// let o = Owned::new(1234);
1038
    /// let guard = &epoch::pin();
1039
    /// let p = o.into_shared(guard);
1040
    /// ```
1041
    #[allow(clippy::needless_lifetimes)]
1042
3.99M
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
3.99M
        unsafe { Shared::from_usize(self.into_usize()) }
1044
3.99M
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::into_shared
Line
Count
Source
1042
260
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
260
        unsafe { Shared::from_usize(self.into_usize()) }
1044
260
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::internal::Local>>::into_shared
Line
Count
Source
1042
146
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
146
        unsafe { Shared::from_usize(self.into_usize()) }
1044
146
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::into_shared
Line
Count
Source
1042
10
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
10
        unsafe { Shared::from_usize(self.into_usize()) }
1044
10
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>::into_shared
Line
Count
Source
1042
16
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
16
        unsafe { Shared::from_usize(self.into_usize()) }
1044
16
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::into_shared
Line
Count
Source
1042
15
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
15
        unsafe { Shared::from_usize(self.into_usize()) }
1044
15
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::into_shared
Line
Count
Source
1042
10
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
10
        unsafe { Shared::from_usize(self.into_usize()) }
1044
10
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::into_shared
Line
Count
Source
1042
11
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
11
        unsafe { Shared::from_usize(self.into_usize()) }
1044
11
    }
<crossbeam_epoch::atomic::Owned<crossbeam_deque::deque::Buffer<usize>>>::into_shared
Line
Count
Source
1042
10
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
10
        unsafe { Shared::from_usize(self.into_usize()) }
1044
10
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::list::Entry>>::into_shared
Line
Count
Source
1042
8.12k
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
8.12k
        unsafe { Shared::from_usize(self.into_usize()) }
1044
8.12k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::collector::tests::stress::Elem>>::into_shared
Line
Count
Source
1042
711k
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
711k
        unsafe { Shared::from_usize(self.into_usize()) }
1044
711k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::collector::tests::count_drops::Elem>>::into_shared
Line
Count
Source
1042
100k
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
100k
        unsafe { Shared::from_usize(self.into_usize()) }
1044
100k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<i64>>>::into_shared
Line
Count
Source
1042
2.91M
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
2.91M
        unsafe { Shared::from_usize(self.into_usize()) }
1044
2.91M
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::into_shared
Line
Count
Source
1042
64.9k
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
64.9k
        unsafe { Shared::from_usize(self.into_usize()) }
1044
64.9k
    }
<crossbeam_epoch::atomic::Owned<i32>>::into_shared
Line
Count
Source
1042
196k
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
196k
        unsafe { Shared::from_usize(self.into_usize()) }
1044
196k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::internal::Local>>::into_shared
Line
Count
Source
1042
70
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
70
        unsafe { Shared::from_usize(self.into_usize()) }
1044
70
    }
<crossbeam_epoch::atomic::Owned<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>>>::into_shared
Line
Count
Source
1042
1
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
1
        unsafe { Shared::from_usize(self.into_usize()) }
1044
1
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::into_shared
Line
Count
Source
1042
5
    pub fn into_shared<'g>(self, _: &'g Guard) -> Shared<'g, T> {
1043
5
        unsafe { Shared::from_usize(self.into_usize()) }
1044
5
    }
1045
1046
    /// Returns the tag stored within the pointer.
1047
    ///
1048
    /// # Examples
1049
    ///
1050
    /// ```
1051
    /// use crossbeam_epoch::Owned;
1052
    ///
1053
    /// assert_eq!(Owned::new(1234).tag(), 0);
1054
    /// ```
1055
0
    pub fn tag(&self) -> usize {
1056
0
        let (_, tag) = decompose_tag::<T>(self.data);
1057
0
        tag
1058
0
    }
1059
1060
    /// Returns the same pointer, but tagged with `tag`. `tag` is truncated to be fit into the
1061
    /// unused bits of the pointer to `T`.
1062
    ///
1063
    /// # Examples
1064
    ///
1065
    /// ```
1066
    /// use crossbeam_epoch::Owned;
1067
    ///
1068
    /// let o = Owned::new(0u64);
1069
    /// assert_eq!(o.tag(), 0);
1070
    /// let o = o.with_tag(2);
1071
    /// assert_eq!(o.tag(), 2);
1072
    /// ```
1073
0
    pub fn with_tag(self, tag: usize) -> Owned<T> {
1074
0
        let data = self.into_usize();
1075
0
        unsafe { Self::from_usize(compose_tag::<T>(data, tag)) }
1076
0
    }
1077
}
1078
1079
impl<T: ?Sized + Pointable> Drop for Owned<T> {
1080
3.83M
    fn drop(&mut self) {
1081
3.83M
        let (raw, _) = decompose_tag::<T>(self.data);
1082
3.83M
        unsafe {
1083
3.83M
            T::drop(raw);
1084
3.83M
        }
1085
3.83M
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::internal::Local> as core::ops::drop::Drop>::drop
Line
Count
Source
1080
70
    fn drop(&mut self) {
1081
70
        let (raw, _) = decompose_tag::<T>(self.data);
1082
70
        unsafe {
1083
70
            T::drop(raw);
1084
70
        }
1085
70
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>> as core::ops::drop::Drop>::drop
Line
Count
Source
1080
133
    fn drop(&mut self) {
1081
133
        let (raw, _) = decompose_tag::<T>(self.data);
1082
133
        unsafe {
1083
133
            T::drop(raw);
1084
133
        }
1085
133
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>> as core::ops::drop::Drop>::drop
Line
Count
Source
1080
5
    fn drop(&mut self) {
1081
5
        let (raw, _) = decompose_tag::<T>(self.data);
1082
5
        unsafe {
1083
5
            T::drop(raw);
1084
5
        }
1085
5
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::collector::tests::stress::Elem> as core::ops::drop::Drop>::drop
Line
Count
Source
1080
735k
    fn drop(&mut self) {
1081
735k
        let (raw, _) = decompose_tag::<T>(self.data);
1082
735k
        unsafe {
1083
735k
            T::drop(raw);
1084
735k
        }
1085
735k
    }
<crossbeam_epoch::atomic::Owned<i32> as core::ops::drop::Drop>::drop
Line
Count
Source
1080
198k
    fn drop(&mut self) {
1081
198k
        let (raw, _) = decompose_tag::<T>(self.data);
1082
198k
        unsafe {
1083
198k
            T::drop(raw);
1084
198k
        }
1085
198k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::list::Entry> as core::ops::drop::Drop>::drop
Line
Count
Source
1080
8.19k
    fn drop(&mut self) {
1081
8.19k
        let (raw, _) = decompose_tag::<T>(self.data);
1082
8.19k
        unsafe {
1083
8.19k
            T::drop(raw);
1084
8.19k
        }
1085
8.19k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::collector::tests::count_drops::Elem> as core::ops::drop::Drop>::drop
Line
Count
Source
1080
100k
    fn drop(&mut self) {
1081
100k
        let (raw, _) = decompose_tag::<T>(self.data);
1082
100k
        unsafe {
1083
100k
            T::drop(raw);
1084
100k
        }
1085
100k
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>> as core::ops::drop::Drop>::drop
Line
Count
Source
1080
64.6k
    fn drop(&mut self) {
1081
64.6k
        let (raw, _) = decompose_tag::<T>(self.data);
1082
64.6k
        unsafe {
1083
64.6k
            T::drop(raw);
1084
64.6k
        }
1085
64.6k
    }
<crossbeam_epoch::atomic::Owned<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>> as core::ops::drop::Drop>::drop
Line
Count
Source
1080
1
    fn drop(&mut self) {
1081
1
        let (raw, _) = decompose_tag::<T>(self.data);
1082
1
        unsafe {
1083
1
            T::drop(raw);
1084
1
        }
1085
1
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::sync::queue::Node<i64>> as core::ops::drop::Drop>::drop
Line
Count
Source
1080
2.72M
    fn drop(&mut self) {
1081
2.72M
        let (raw, _) = decompose_tag::<T>(self.data);
1082
2.72M
        unsafe {
1083
2.72M
            T::drop(raw);
1084
2.72M
        }
1085
2.72M
    }
<crossbeam_epoch::atomic::Owned<crossbeam_epoch::internal::Local> as core::ops::drop::Drop>::drop
Line
Count
Source
1080
65
    fn drop(&mut self) {
1081
65
        let (raw, _) = decompose_tag::<T>(self.data);
1082
65
        unsafe {
1083
65
            T::drop(raw);
1084
65
        }
1085
65
    }
1086
}
1087
1088
impl<T: ?Sized + Pointable> fmt::Debug for Owned<T> {
1089
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1090
0
        let (raw, tag) = decompose_tag::<T>(self.data);
1091
0
1092
0
        f.debug_struct("Owned")
1093
0
            .field("raw", &raw)
1094
0
            .field("tag", &tag)
1095
0
            .finish()
1096
0
    }
1097
}
1098
1099
impl<T: Clone> Clone for Owned<T> {
1100
0
    fn clone(&self) -> Self {
1101
0
        Owned::new((**self).clone()).with_tag(self.tag())
1102
0
    }
1103
}
1104
1105
impl<T: ?Sized + Pointable> Deref for Owned<T> {
1106
    type Target = T;
1107
1108
0
    fn deref(&self) -> &T {
1109
0
        let (raw, _) = decompose_tag::<T>(self.data);
1110
0
        unsafe { T::deref(raw) }
1111
0
    }
1112
}
1113
1114
impl<T: ?Sized + Pointable> DerefMut for Owned<T> {
1115
0
    fn deref_mut(&mut self) -> &mut T {
1116
0
        let (raw, _) = decompose_tag::<T>(self.data);
1117
0
        unsafe { T::deref_mut(raw) }
1118
0
    }
1119
}
1120
1121
impl<T> From<T> for Owned<T> {
1122
0
    fn from(t: T) -> Self {
1123
0
        Owned::new(t)
1124
0
    }
1125
}
1126
1127
impl<T> From<Box<T>> for Owned<T> {
1128
    /// Returns a new owned pointer pointing to `b`.
1129
    ///
1130
    /// # Panics
1131
    ///
1132
    /// Panics if the pointer (the `Box`) is not properly aligned.
1133
    ///
1134
    /// # Examples
1135
    ///
1136
    /// ```
1137
    /// use crossbeam_epoch::Owned;
1138
    ///
1139
    /// let o = unsafe { Owned::from_raw(Box::into_raw(Box::new(1234))) };
1140
    /// ```
1141
0
    fn from(b: Box<T>) -> Self {
1142
0
        unsafe { Self::from_raw(Box::into_raw(b)) }
1143
0
    }
1144
}
1145
1146
impl<T: ?Sized + Pointable> Borrow<T> for Owned<T> {
1147
0
    fn borrow(&self) -> &T {
1148
0
        self.deref()
1149
0
    }
1150
}
1151
1152
impl<T: ?Sized + Pointable> BorrowMut<T> for Owned<T> {
1153
0
    fn borrow_mut(&mut self) -> &mut T {
1154
0
        self.deref_mut()
1155
0
    }
1156
}
1157
1158
impl<T: ?Sized + Pointable> AsRef<T> for Owned<T> {
1159
0
    fn as_ref(&self) -> &T {
1160
0
        self.deref()
1161
0
    }
1162
}
1163
1164
impl<T: ?Sized + Pointable> AsMut<T> for Owned<T> {
1165
0
    fn as_mut(&mut self) -> &mut T {
1166
0
        self.deref_mut()
1167
0
    }
1168
}
1169
1170
/// A pointer to an object protected by the epoch GC.
1171
///
1172
/// The pointer is valid for use only during the lifetime `'g`.
1173
///
1174
/// The pointer must be properly aligned. Since it is aligned, a tag can be stored into the unused
1175
/// least significant bits of the address.
1176
pub struct Shared<'g, T: 'g + ?Sized + Pointable> {
1177
    data: usize,
1178
    _marker: PhantomData<(&'g (), *const T)>,
1179
}
1180
1181
impl<T: ?Sized + Pointable> Clone for Shared<'_, T> {
1182
0
    fn clone(&self) -> Self {
1183
0
        Self {
1184
0
            data: self.data,
1185
0
            _marker: PhantomData,
1186
0
        }
1187
0
    }
1188
}
1189
1190
impl<T: ?Sized + Pointable> Copy for Shared<'_, T> {}
1191
1192
impl<T: ?Sized + Pointable> Pointer<T> for Shared<'_, T> {
1193
    #[inline]
1194
16.8M
    fn into_usize(self) -> usize {
1195
16.8M
        self.data
1196
16.8M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>> as crossbeam_epoch::atomic::Pointer<crossbeam_skiplist::base::Node<i32, i32>>>::into_usize
Line
Count
Source
1194
86
    fn into_usize(self) -> usize {
1195
86
        self.data
1196
86
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::into_usize
Line
Count
Source
1194
1.34k
    fn into_usize(self) -> usize {
1195
1.34k
        self.data
1196
1.34k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::list::Entry>>::into_usize
Line
Count
Source
1194
636
    fn into_usize(self) -> usize {
1195
636
        self.data
1196
636
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, ()>> as crossbeam_epoch::atomic::Pointer<crossbeam_skiplist::base::Node<i32, ()>>>::into_usize
Line
Count
Source
1194
9
    fn into_usize(self) -> usize {
1195
9
        self.data
1196
9
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>> as crossbeam_epoch::atomic::Pointer<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::into_usize
Line
Count
Source
1194
27
    fn into_usize(self) -> usize {
1195
27
        self.data
1196
27
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>> as crossbeam_epoch::atomic::Pointer<crossbeam_skiplist::base::Node<i32, i32>>>::into_usize
Line
Count
Source
1194
586
    fn into_usize(self) -> usize {
1195
586
        self.data
1196
586
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<usize>>>::into_usize
Line
Count
Source
1194
16
    fn into_usize(self) -> usize {
1195
16
        self.data
1196
16
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::into_usize
Line
Count
Source
1194
10
    fn into_usize(self) -> usize {
1195
10
        self.data
1196
10
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::into_usize
Line
Count
Source
1194
15
    fn into_usize(self) -> usize {
1195
15
        self.data
1196
15
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::into_usize
Line
Count
Source
1194
10
    fn into_usize(self) -> usize {
1195
10
        self.data
1196
10
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::into_usize
Line
Count
Source
1194
11
    fn into_usize(self) -> usize {
1195
11
        self.data
1196
11
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<usize>>>::into_usize
Line
Count
Source
1194
10
    fn into_usize(self) -> usize {
1195
10
        self.data
1196
10
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::list::Entry>>::into_usize
Line
Count
Source
1194
45.0k
    fn into_usize(self) -> usize {
1195
45.0k
        self.data
1196
45.0k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<i64>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<i64>>>::into_usize
Line
Count
Source
1194
16.3M
    fn into_usize(self) -> usize {
1195
16.3M
        self.data
1196
16.3M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::into_usize
Line
Count
Source
1194
392k
    fn into_usize(self) -> usize {
1195
392k
        self.data
1196
392k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::into_usize
Line
Count
Source
1194
26
    fn into_usize(self) -> usize {
1195
26
        self.data
1196
26
    }
1197
1198
    #[inline]
1199
50.0M
    unsafe fn from_usize(data: usize) -> Self {
1200
50.0M
        Shared {
1201
50.0M
            data,
1202
50.0M
            _marker: PhantomData,
1203
50.0M
        }
1204
50.0M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>> as crossbeam_epoch::atomic::Pointer<crossbeam_skiplist::base::Node<i32, i32>>>::from_usize
Line
Count
Source
1199
859
    unsafe fn from_usize(data: usize) -> Self {
1200
859
        Shared {
1201
859
            data,
1202
859
            _marker: PhantomData,
1203
859
        }
1204
859
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::from_usize
Line
Count
Source
1199
21.2k
    unsafe fn from_usize(data: usize) -> Self {
1200
21.2k
        Shared {
1201
21.2k
            data,
1202
21.2k
            _marker: PhantomData,
1203
21.2k
        }
1204
21.2k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::list::Entry>>::from_usize
Line
Count
Source
1199
96.8k
    unsafe fn from_usize(data: usize) -> Self {
1200
96.8k
        Shared {
1201
96.8k
            data,
1202
96.8k
            _marker: PhantomData,
1203
96.8k
        }
1204
96.8k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::internal::Local> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::internal::Local>>::from_usize
Line
Count
Source
1199
245
    unsafe fn from_usize(data: usize) -> Self {
1200
245
        Shared {
1201
245
            data,
1202
245
            _marker: PhantomData,
1203
245
        }
1204
245
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<usize>>>::from_usize
Line
Count
Source
1199
13
    unsafe fn from_usize(data: usize) -> Self {
1200
13
        Shared {
1201
13
            data,
1202
13
            _marker: PhantomData,
1203
13
        }
1204
13
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<injector::destructors::Elem>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>>::from_usize
Line
Count
Source
1199
8
    unsafe fn from_usize(data: usize) -> Self {
1200
8
        Shared {
1201
8
            data,
1202
8
            _marker: PhantomData,
1203
8
        }
1204
8
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, ()>> as crossbeam_epoch::atomic::Pointer<crossbeam_skiplist::base::Node<i32, ()>>>::from_usize
Line
Count
Source
1199
21
    unsafe fn from_usize(data: usize) -> Self {
1200
21
        Shared {
1201
21
            data,
1202
21
            _marker: PhantomData,
1203
21
        }
1204
21
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>> as crossbeam_epoch::atomic::Pointer<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::from_usize
Line
Count
Source
1199
71
    unsafe fn from_usize(data: usize) -> Self {
1200
71
        Shared {
1201
71
            data,
1202
71
            _marker: PhantomData,
1203
71
        }
1204
71
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>> as crossbeam_epoch::atomic::Pointer<crossbeam_skiplist::base::Node<i32, i32>>>::from_usize
Line
Count
Source
1199
2.52k
    unsafe fn from_usize(data: usize) -> Self {
1200
2.52k
        Shared {
1201
2.52k
            data,
1202
2.52k
            _marker: PhantomData,
1203
2.52k
        }
1204
2.52k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<alloc::string::String, alloc::boxed::Box<i32>>> as crossbeam_epoch::atomic::Pointer<crossbeam_skiplist::base::Node<alloc::string::String, alloc::boxed::Box<i32>>>>::from_usize
Line
Count
Source
1199
1
    unsafe fn from_usize(data: usize) -> Self {
1200
1
        Shared {
1201
1
            data,
1202
1
            _marker: PhantomData,
1203
1
        }
1204
1
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<i32>>>::from_usize
Line
Count
Source
1199
1
    unsafe fn from_usize(data: usize) -> Self {
1200
1
        Shared {
1201
1
            data,
1202
1
            _marker: PhantomData,
1203
1
        }
1204
1
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::from_usize
Line
Count
Source
1199
45.5k
    unsafe fn from_usize(data: usize) -> Self {
1200
45.5k
        Shared {
1201
45.5k
            data,
1202
45.5k
            _marker: PhantomData,
1203
45.5k
        }
1204
45.5k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<usize>>>::from_usize
Line
Count
Source
1199
171k
    unsafe fn from_usize(data: usize) -> Self {
1200
171k
        Shared {
1201
171k
            data,
1202
171k
            _marker: PhantomData,
1203
171k
        }
1204
171k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<i32>>>::from_usize
Line
Count
Source
1199
9
    unsafe fn from_usize(data: usize) -> Self {
1200
9
        Shared {
1201
9
            data,
1202
9
            _marker: PhantomData,
1203
9
        }
1204
9
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::from_usize
Line
Count
Source
1199
464
    unsafe fn from_usize(data: usize) -> Self {
1200
464
        Shared {
1201
464
            data,
1202
464
            _marker: PhantomData,
1203
464
        }
1204
464
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<i32>>>::from_usize
Line
Count
Source
1199
36
    unsafe fn from_usize(data: usize) -> Self {
1200
36
        Shared {
1201
36
            data,
1202
36
            _marker: PhantomData,
1203
36
        }
1204
36
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<i32>>>::from_usize
Line
Count
Source
1199
9
    unsafe fn from_usize(data: usize) -> Self {
1200
9
        Shared {
1201
9
            data,
1202
9
            _marker: PhantomData,
1203
9
        }
1204
9
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::from_usize
Line
Count
Source
1199
85.1k
    unsafe fn from_usize(data: usize) -> Self {
1200
85.1k
        Shared {
1201
85.1k
            data,
1202
85.1k
            _marker: PhantomData,
1203
85.1k
        }
1204
85.1k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<usize>>>::from_usize
Line
Count
Source
1199
194k
    unsafe fn from_usize(data: usize) -> Self {
1200
194k
        Shared {
1201
194k
            data,
1202
194k
            _marker: PhantomData,
1203
194k
        }
1204
194k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>> as crossbeam_epoch::atomic::Pointer<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::from_usize
Line
Count
Source
1199
1.30k
    unsafe fn from_usize(data: usize) -> Self {
1200
1.30k
        Shared {
1201
1.30k
            data,
1202
1.30k
            _marker: PhantomData,
1203
1.30k
        }
1204
1.30k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::collector::tests::stress::Elem> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::collector::tests::stress::Elem>>::from_usize
Line
Count
Source
1199
738k
    unsafe fn from_usize(data: usize) -> Self {
1200
738k
        Shared {
1201
738k
            data,
1202
738k
            _marker: PhantomData,
1203
738k
        }
1204
738k
    }
<crossbeam_epoch::atomic::Shared<i64> as crossbeam_epoch::atomic::Pointer<i64>>::from_usize
Line
Count
Source
1199
1
    unsafe fn from_usize(data: usize) -> Self {
1200
1
        Shared {
1201
1
            data,
1202
1
            _marker: PhantomData,
1203
1
        }
1204
1
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<i64>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<i64>>>::from_usize
Line
Count
Source
1199
23.4M
    unsafe fn from_usize(data: usize) -> Self {
1200
23.4M
        Shared {
1201
23.4M
            data,
1202
23.4M
            _marker: PhantomData,
1203
23.4M
        }
1204
23.4M
    }
<crossbeam_epoch::atomic::Shared<i32> as crossbeam_epoch::atomic::Pointer<i32>>::from_usize
Line
Count
Source
1199
195k
    unsafe fn from_usize(data: usize) -> Self {
1200
195k
        Shared {
1201
195k
            data,
1202
195k
            _marker: PhantomData,
1203
195k
        }
1204
195k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::from_usize
Line
Count
Source
1199
7.33M
    unsafe fn from_usize(data: usize) -> Self {
1200
7.33M
        Shared {
1201
7.33M
            data,
1202
7.33M
            _marker: PhantomData,
1203
7.33M
        }
1204
7.33M
    }
<crossbeam_epoch::atomic::Shared<i8> as crossbeam_epoch::atomic::Pointer<i8>>::from_usize
Line
Count
Source
1199
1
    unsafe fn from_usize(data: usize) -> Self {
1200
1
        Shared {
1201
1
            data,
1202
1
            _marker: PhantomData,
1203
1
        }
1204
1
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::from_usize
Line
Count
Source
1199
3.81M
    unsafe fn from_usize(data: usize) -> Self {
1200
3.81M
        Shared {
1201
3.81M
            data,
1202
3.81M
            _marker: PhantomData,
1203
3.81M
        }
1204
3.81M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::sync::list::Entry>>::from_usize
Line
Count
Source
1199
13.7M
    unsafe fn from_usize(data: usize) -> Self {
1200
13.7M
        Shared {
1201
13.7M
            data,
1202
13.7M
            _marker: PhantomData,
1203
13.7M
        }
1204
13.7M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::collector::tests::count_drops::Elem> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::collector::tests::count_drops::Elem>>::from_usize
Line
Count
Source
1199
100k
    unsafe fn from_usize(data: usize) -> Self {
1200
100k
        Shared {
1201
100k
            data,
1202
100k
            _marker: PhantomData,
1203
100k
        }
1204
100k
    }
<crossbeam_epoch::atomic::Shared<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>> as crossbeam_epoch::atomic::Pointer<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>>>::from_usize
Line
Count
Source
1199
1
    unsafe fn from_usize(data: usize) -> Self {
1200
1
        Shared {
1201
1
            data,
1202
1
            _marker: PhantomData,
1203
1
        }
1204
1
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::internal::Local> as crossbeam_epoch::atomic::Pointer<crossbeam_epoch::internal::Local>>::from_usize
Line
Count
Source
1199
137
    unsafe fn from_usize(data: usize) -> Self {
1200
137
        Shared {
1201
137
            data,
1202
137
            _marker: PhantomData,
1203
137
        }
1204
137
    }
1205
}
1206
1207
impl<'g, T> Shared<'g, T> {
1208
    /// Converts the pointer to a raw pointer (without the tag).
1209
    ///
1210
    /// # Examples
1211
    ///
1212
    /// ```
1213
    /// use crossbeam_epoch::{self as epoch, Atomic, Owned};
1214
    /// use std::sync::atomic::Ordering::SeqCst;
1215
    ///
1216
    /// let o = Owned::new(1234);
1217
    /// let raw = &*o as *const _;
1218
    /// let a = Atomic::from(o);
1219
    ///
1220
    /// let guard = &epoch::pin();
1221
    /// let p = a.load(SeqCst, guard);
1222
    /// assert_eq!(p.as_raw(), raw);
1223
    /// ```
1224
    #[allow(clippy::trivially_copy_pass_by_ref)]
1225
229
    pub fn as_raw(&self) -> *const T {
1226
229
        let (raw, _) = decompose_tag::<T>(self.data);
1227
229
        raw as *const _
1228
229
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::internal::Local>>::as_raw
Line
Count
Source
1225
146
    pub fn as_raw(&self) -> *const T {
1226
146
        let (raw, _) = decompose_tag::<T>(self.data);
1227
146
        raw as *const _
1228
146
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::as_raw
Line
Count
Source
1225
8
    pub fn as_raw(&self) -> *const T {
1226
8
        let (raw, _) = decompose_tag::<T>(self.data);
1227
8
        raw as *const _
1228
8
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::as_raw
Line
Count
Source
1225
5
    pub fn as_raw(&self) -> *const T {
1226
5
        let (raw, _) = decompose_tag::<T>(self.data);
1227
5
        raw as *const _
1228
5
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::internal::Local>>::as_raw
Line
Count
Source
1225
70
    pub fn as_raw(&self) -> *const T {
1226
70
        let (raw, _) = decompose_tag::<T>(self.data);
1227
70
        raw as *const _
1228
70
    }
1229
}
1230
1231
impl<'g, T: ?Sized + Pointable> Shared<'g, T> {
1232
    /// Returns a new null pointer.
1233
    ///
1234
    /// # Examples
1235
    ///
1236
    /// ```
1237
    /// use crossbeam_epoch::Shared;
1238
    ///
1239
    /// let p = Shared::<i32>::null();
1240
    /// assert!(p.is_null());
1241
    /// ```
1242
2.87M
    pub fn null() -> Shared<'g, T> {
1243
2.87M
        Shared {
1244
2.87M
            data: 0,
1245
2.87M
            _marker: PhantomData,
1246
2.87M
        }
1247
2.87M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::null
Line
Count
Source
1242
24
    pub fn null() -> Shared<'g, T> {
1243
24
        Shared {
1244
24
            data: 0,
1245
24
            _marker: PhantomData,
1246
24
        }
1247
24
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::null
Line
Count
Source
1242
225
    pub fn null() -> Shared<'g, T> {
1243
225
        Shared {
1244
225
            data: 0,
1245
225
            _marker: PhantomData,
1246
225
        }
1247
225
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, ()>>>::null
Line
Count
Source
1242
3
    pub fn null() -> Shared<'g, T> {
1243
3
        Shared {
1244
3
            data: 0,
1245
3
            _marker: PhantomData,
1246
3
        }
1247
3
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::null
Line
Count
Source
1242
194
    pub fn null() -> Shared<'g, T> {
1243
194
        Shared {
1244
194
            data: 0,
1245
194
            _marker: PhantomData,
1246
194
        }
1247
194
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::null
Line
Count
Source
1242
8
    pub fn null() -> Shared<'g, T> {
1243
8
        Shared {
1244
8
            data: 0,
1245
8
            _marker: PhantomData,
1246
8
        }
1247
8
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::null
Line
Count
Source
1242
65.1k
    pub fn null() -> Shared<'g, T> {
1243
65.1k
        Shared {
1244
65.1k
            data: 0,
1245
65.1k
            _marker: PhantomData,
1246
65.1k
        }
1247
65.1k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<i64>>>::null
Line
Count
Source
1242
2.80M
    pub fn null() -> Shared<'g, T> {
1243
2.80M
        Shared {
1244
2.80M
            data: 0,
1245
2.80M
            _marker: PhantomData,
1246
2.80M
        }
1247
2.80M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::null
Line
Count
Source
1242
4
    pub fn null() -> Shared<'g, T> {
1243
4
        Shared {
1244
4
            data: 0,
1245
4
            _marker: PhantomData,
1246
4
        }
1247
4
    }
<crossbeam_epoch::atomic::Shared<i8>>::null
Line
Count
Source
1242
1
    pub fn null() -> Shared<'g, T> {
1243
1
        Shared {
1244
1
            data: 0,
1245
1
            _marker: PhantomData,
1246
1
        }
1247
1
    }
<crossbeam_epoch::atomic::Shared<i64>>::null
Line
Count
Source
1242
1
    pub fn null() -> Shared<'g, T> {
1243
1
        Shared {
1244
1
            data: 0,
1245
1
            _marker: PhantomData,
1246
1
        }
1247
1
    }
1248
1249
    /// Returns `true` if the pointer is null.
1250
    ///
1251
    /// # Examples
1252
    ///
1253
    /// ```
1254
    /// use crossbeam_epoch::{self as epoch, Atomic, Owned};
1255
    /// use std::sync::atomic::Ordering::SeqCst;
1256
    ///
1257
    /// let a = Atomic::null();
1258
    /// let guard = &epoch::pin();
1259
    /// assert!(a.load(SeqCst, guard).is_null());
1260
    /// a.store(Owned::new(1234), SeqCst);
1261
    /// assert!(!a.load(SeqCst, guard).is_null());
1262
    /// ```
1263
    #[allow(clippy::trivially_copy_pass_by_ref)]
1264
3.81M
    pub fn is_null(&self) -> bool {
1265
3.81M
        let (raw, _) = decompose_tag::<T>(self.data);
1266
3.81M
        raw == 0
1267
3.81M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::is_null
Line
Count
Source
1264
71
    pub fn is_null(&self) -> bool {
1265
71
        let (raw, _) = decompose_tag::<T>(self.data);
1266
71
        raw == 0
1267
71
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::internal::Local>>::is_null
Line
Count
Source
1264
70
    pub fn is_null(&self) -> bool {
1265
70
        let (raw, _) = decompose_tag::<T>(self.data);
1266
70
        raw == 0
1267
70
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::is_null
Line
Count
Source
1264
133
    pub fn is_null(&self) -> bool {
1265
133
        let (raw, _) = decompose_tag::<T>(self.data);
1266
133
        raw == 0
1267
133
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>>::is_null
Line
Count
Source
1264
8
    pub fn is_null(&self) -> bool {
1265
8
        let (raw, _) = decompose_tag::<T>(self.data);
1266
8
        raw == 0
1267
8
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>>>::is_null
Line
Count
Source
1264
13
    pub fn is_null(&self) -> bool {
1265
13
        let (raw, _) = decompose_tag::<T>(self.data);
1266
13
        raw == 0
1267
13
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, ()>>>::is_null
Line
Count
Source
1264
3
    pub fn is_null(&self) -> bool {
1265
3
        let (raw, _) = decompose_tag::<T>(self.data);
1266
3
        raw == 0
1267
3
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::is_null
Line
Count
Source
1264
8
    pub fn is_null(&self) -> bool {
1265
8
        let (raw, _) = decompose_tag::<T>(self.data);
1266
8
        raw == 0
1267
8
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::is_null
Line
Count
Source
1264
314
    pub fn is_null(&self) -> bool {
1265
314
        let (raw, _) = decompose_tag::<T>(self.data);
1266
314
        raw == 0
1267
314
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>>>::is_null
Line
Count
Source
1264
1
    pub fn is_null(&self) -> bool {
1265
1
        let (raw, _) = decompose_tag::<T>(self.data);
1266
1
        raw == 0
1267
1
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>>>::is_null
Line
Count
Source
1264
2
    pub fn is_null(&self) -> bool {
1265
2
        let (raw, _) = decompose_tag::<T>(self.data);
1266
2
        raw == 0
1267
2
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>>>::is_null
Line
Count
Source
1264
32
    pub fn is_null(&self) -> bool {
1265
32
        let (raw, _) = decompose_tag::<T>(self.data);
1266
32
        raw == 0
1267
32
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::is_null
Line
Count
Source
1264
16
    pub fn is_null(&self) -> bool {
1265
16
        let (raw, _) = decompose_tag::<T>(self.data);
1266
16
        raw == 0
1267
16
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::is_null
Line
Count
Source
1264
19
    pub fn is_null(&self) -> bool {
1265
19
        let (raw, _) = decompose_tag::<T>(self.data);
1266
19
        raw == 0
1267
19
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>>>::is_null
Line
Count
Source
1264
22
    pub fn is_null(&self) -> bool {
1265
22
        let (raw, _) = decompose_tag::<T>(self.data);
1266
22
        raw == 0
1267
22
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>>>::is_null
Line
Count
Source
1264
28
    pub fn is_null(&self) -> bool {
1265
28
        let (raw, _) = decompose_tag::<T>(self.data);
1266
28
        raw == 0
1267
28
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::is_null
Line
Count
Source
1264
12
    pub fn is_null(&self) -> bool {
1265
12
        let (raw, _) = decompose_tag::<T>(self.data);
1266
12
        raw == 0
1267
12
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>>>::is_null
Line
Count
Source
1264
2
    pub fn is_null(&self) -> bool {
1265
2
        let (raw, _) = decompose_tag::<T>(self.data);
1266
2
        raw == 0
1267
2
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::is_null
Line
Count
Source
1264
19
    pub fn is_null(&self) -> bool {
1265
19
        let (raw, _) = decompose_tag::<T>(self.data);
1266
19
        raw == 0
1267
19
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::collector::tests::stress::Elem>>::is_null
Line
Count
Source
1264
705k
    pub fn is_null(&self) -> bool {
1265
705k
        let (raw, _) = decompose_tag::<T>(self.data);
1266
705k
        raw == 0
1267
705k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<i64>>>::is_null
Line
Count
Source
1264
2.73M
    pub fn is_null(&self) -> bool {
1265
2.73M
        let (raw, _) = decompose_tag::<T>(self.data);
1266
2.73M
        raw == 0
1267
2.73M
    }
<crossbeam_epoch::atomic::Shared<i32>>::is_null
Line
Count
Source
1264
197k
    pub fn is_null(&self) -> bool {
1265
197k
        let (raw, _) = decompose_tag::<T>(self.data);
1266
197k
        raw == 0
1267
197k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::is_null
Line
Count
Source
1264
64.5k
    pub fn is_null(&self) -> bool {
1265
64.5k
        let (raw, _) = decompose_tag::<T>(self.data);
1266
64.5k
        raw == 0
1267
64.5k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::is_null
Line
Count
Source
1264
8.19k
    pub fn is_null(&self) -> bool {
1265
8.19k
        let (raw, _) = decompose_tag::<T>(self.data);
1266
8.19k
        raw == 0
1267
8.19k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::is_null
Line
Count
Source
1264
6
    pub fn is_null(&self) -> bool {
1265
6
        let (raw, _) = decompose_tag::<T>(self.data);
1266
6
        raw == 0
1267
6
    }
<crossbeam_epoch::atomic::Shared<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>>>::is_null
Line
Count
Source
1264
1
    pub fn is_null(&self) -> bool {
1265
1
        let (raw, _) = decompose_tag::<T>(self.data);
1266
1
        raw == 0
1267
1
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::collector::tests::count_drops::Elem>>::is_null
Line
Count
Source
1264
100k
    pub fn is_null(&self) -> bool {
1265
100k
        let (raw, _) = decompose_tag::<T>(self.data);
1266
100k
        raw == 0
1267
100k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::internal::Local>>::is_null
Line
Count
Source
1264
65
    pub fn is_null(&self) -> bool {
1265
65
        let (raw, _) = decompose_tag::<T>(self.data);
1266
65
        raw == 0
1267
65
    }
1268
1269
    /// Dereferences the pointer.
1270
    ///
1271
    /// Returns a reference to the pointee that is valid during the lifetime `'g`.
1272
    ///
1273
    /// # Safety
1274
    ///
1275
    /// Dereferencing a pointer is unsafe because it could be pointing to invalid memory.
1276
    ///
1277
    /// Another concern is the possibility of data races due to lack of proper synchronization.
1278
    /// For example, consider the following scenario:
1279
    ///
1280
    /// 1. A thread creates a new object: `a.store(Owned::new(10), Relaxed)`
1281
    /// 2. Another thread reads it: `*a.load(Relaxed, guard).as_ref().unwrap()`
1282
    ///
1283
    /// The problem is that relaxed orderings don't synchronize initialization of the object with
1284
    /// the read from the second thread. This is a data race. A possible solution would be to use
1285
    /// `Release` and `Acquire` orderings.
1286
    ///
1287
    /// # Examples
1288
    ///
1289
    /// ```
1290
    /// use crossbeam_epoch::{self as epoch, Atomic};
1291
    /// use std::sync::atomic::Ordering::SeqCst;
1292
    ///
1293
    /// let a = Atomic::new(1234);
1294
    /// let guard = &epoch::pin();
1295
    /// let p = a.load(SeqCst, guard);
1296
    /// unsafe {
1297
    ///     assert_eq!(p.deref(), &1234);
1298
    /// }
1299
    /// ```
1300
    #[allow(clippy::trivially_copy_pass_by_ref)]
1301
    #[allow(clippy::should_implement_trait)]
1302
14.4M
    pub unsafe fn deref(&self) -> &'g T {
1303
14.4M
        let (raw, _) = decompose_tag::<T>(self.data);
1304
14.4M
        T::deref(raw)
1305
14.4M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::deref
Line
Count
Source
1302
10.1k
    pub unsafe fn deref(&self) -> &'g T {
1303
10.1k
        let (raw, _) = decompose_tag::<T>(self.data);
1304
10.1k
        T::deref(raw)
1305
10.1k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::deref
Line
Count
Source
1302
99
    pub unsafe fn deref(&self) -> &'g T {
1303
99
        let (raw, _) = decompose_tag::<T>(self.data);
1304
99
        T::deref(raw)
1305
99
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::internal::Local>>::deref
Line
Count
Source
1302
146
    pub unsafe fn deref(&self) -> &'g T {
1303
146
        let (raw, _) = decompose_tag::<T>(self.data);
1304
146
        T::deref(raw)
1305
146
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>>>::deref
Line
Count
Source
1302
7
    pub unsafe fn deref(&self) -> &'g T {
1303
7
        let (raw, _) = decompose_tag::<T>(self.data);
1304
7
        T::deref(raw)
1305
7
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>>>::deref
Line
Count
Source
1302
595k
    pub unsafe fn deref(&self) -> &'g T {
1303
595k
        let (raw, _) = decompose_tag::<T>(self.data);
1304
595k
        T::deref(raw)
1305
595k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::deref
Line
Count
Source
1302
45.3k
    pub unsafe fn deref(&self) -> &'g T {
1303
45.3k
        let (raw, _) = decompose_tag::<T>(self.data);
1304
45.3k
        T::deref(raw)
1305
45.3k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::deref
Line
Count
Source
1302
50.1k
    pub unsafe fn deref(&self) -> &'g T {
1303
50.1k
        let (raw, _) = decompose_tag::<T>(self.data);
1304
50.1k
        T::deref(raw)
1305
50.1k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>>>::deref
Line
Count
Source
1302
46
    pub unsafe fn deref(&self) -> &'g T {
1303
46
        let (raw, _) = decompose_tag::<T>(self.data);
1304
46
        T::deref(raw)
1305
46
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>>>::deref
Line
Count
Source
1302
220k
    pub unsafe fn deref(&self) -> &'g T {
1303
220k
        let (raw, _) = decompose_tag::<T>(self.data);
1304
220k
        T::deref(raw)
1305
220k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::deref
Line
Count
Source
1302
74.6k
    pub unsafe fn deref(&self) -> &'g T {
1303
74.6k
        let (raw, _) = decompose_tag::<T>(self.data);
1304
74.6k
        T::deref(raw)
1305
74.6k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>>>::deref
Line
Count
Source
1302
7
    pub unsafe fn deref(&self) -> &'g T {
1303
7
        let (raw, _) = decompose_tag::<T>(self.data);
1304
7
        T::deref(raw)
1305
7
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::deref
Line
Count
Source
1302
49.8k
    pub unsafe fn deref(&self) -> &'g T {
1303
49.8k
        let (raw, _) = decompose_tag::<T>(self.data);
1304
49.8k
        T::deref(raw)
1305
49.8k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::deref
Line
Count
Source
1302
3.76M
    pub unsafe fn deref(&self) -> &'g T {
1303
3.76M
        let (raw, _) = decompose_tag::<T>(self.data);
1304
3.76M
        T::deref(raw)
1305
3.76M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::internal::Local>>::deref
Line
Count
Source
1302
70
    pub unsafe fn deref(&self) -> &'g T {
1303
70
        let (raw, _) = decompose_tag::<T>(self.data);
1304
70
        T::deref(raw)
1305
70
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::deref
Line
Count
Source
1302
16.2k
    pub unsafe fn deref(&self) -> &'g T {
1303
16.2k
        let (raw, _) = decompose_tag::<T>(self.data);
1304
16.2k
        T::deref(raw)
1305
16.2k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::deref
Line
Count
Source
1302
1.96M
    pub unsafe fn deref(&self) -> &'g T {
1303
1.96M
        let (raw, _) = decompose_tag::<T>(self.data);
1304
1.96M
        T::deref(raw)
1305
1.96M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<i64>>>::deref
Line
Count
Source
1302
7.65M
    pub unsafe fn deref(&self) -> &'g T {
1303
7.65M
        let (raw, _) = decompose_tag::<T>(self.data);
1304
7.65M
        T::deref(raw)
1305
7.65M
    }
1306
1307
    /// Dereferences the pointer.
1308
    ///
1309
    /// Returns a mutable reference to the pointee that is valid during the lifetime `'g`.
1310
    ///
1311
    /// # Safety
1312
    ///
1313
    /// * There is no guarantee that there are no more threads attempting to read/write from/to the
1314
    ///   actual object at the same time.
1315
    ///
1316
    ///   The user must know that there are no concurrent accesses towards the object itself.
1317
    ///
1318
    /// * Other than the above, all safety concerns of `deref()` applies here.
1319
    ///
1320
    /// # Examples
1321
    ///
1322
    /// ```
1323
    /// use crossbeam_epoch::{self as epoch, Atomic};
1324
    /// use std::sync::atomic::Ordering::SeqCst;
1325
    ///
1326
    /// let a = Atomic::new(vec![1, 2, 3, 4]);
1327
    /// let guard = &epoch::pin();
1328
    ///
1329
    /// let mut p = a.load(SeqCst, guard);
1330
    /// unsafe {
1331
    ///     assert!(!p.is_null());
1332
    ///     let b = p.deref_mut();
1333
    ///     assert_eq!(b, &vec![1, 2, 3, 4]);
1334
    ///     b.push(5);
1335
    ///     assert_eq!(b, &vec![1, 2, 3, 4, 5]);
1336
    /// }
1337
    ///
1338
    /// let p = a.load(SeqCst, guard);
1339
    /// unsafe {
1340
    ///     assert_eq!(p.deref(), &vec![1, 2, 3, 4, 5]);
1341
    /// }
1342
    /// ```
1343
    #[allow(clippy::should_implement_trait)]
1344
0
    pub unsafe fn deref_mut(&mut self) -> &'g mut T {
1345
0
        let (raw, _) = decompose_tag::<T>(self.data);
1346
0
        T::deref_mut(raw)
1347
0
    }
1348
1349
    /// Converts the pointer to a reference.
1350
    ///
1351
    /// Returns `None` if the pointer is null, or else a reference to the object wrapped in `Some`.
1352
    ///
1353
    /// # Safety
1354
    ///
1355
    /// Dereferencing a pointer is unsafe because it could be pointing to invalid memory.
1356
    ///
1357
    /// Another concern is the possibility of data races due to lack of proper synchronization.
1358
    /// For example, consider the following scenario:
1359
    ///
1360
    /// 1. A thread creates a new object: `a.store(Owned::new(10), Relaxed)`
1361
    /// 2. Another thread reads it: `*a.load(Relaxed, guard).as_ref().unwrap()`
1362
    ///
1363
    /// The problem is that relaxed orderings don't synchronize initialization of the object with
1364
    /// the read from the second thread. This is a data race. A possible solution would be to use
1365
    /// `Release` and `Acquire` orderings.
1366
    ///
1367
    /// # Examples
1368
    ///
1369
    /// ```
1370
    /// use crossbeam_epoch::{self as epoch, Atomic};
1371
    /// use std::sync::atomic::Ordering::SeqCst;
1372
    ///
1373
    /// let a = Atomic::new(1234);
1374
    /// let guard = &epoch::pin();
1375
    /// let p = a.load(SeqCst, guard);
1376
    /// unsafe {
1377
    ///     assert_eq!(p.as_ref(), Some(&1234));
1378
    /// }
1379
    /// ```
1380
    #[allow(clippy::trivially_copy_pass_by_ref)]
1381
23.8M
    pub unsafe fn as_ref(&self) -> Option<&'g T> {
1382
23.8M
        let (raw, _) = decompose_tag::<T>(self.data);
1383
23.8M
        if raw == 0 {
1384
10.5M
            None
1385
        } else {
1386
13.3M
            Some(T::deref(raw))
1387
        }
1388
23.8M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::as_ref
Line
Count
Source
1381
465
    pub unsafe fn as_ref(&self) -> Option<&'g T> {
1382
465
        let (raw, _) = decompose_tag::<T>(self.data);
1383
465
        if raw == 0 {
1384
63
            None
1385
        } else {
1386
402
            Some(T::deref(raw))
1387
        }
1388
465
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::as_ref
Line
Count
Source
1381
10.1k
    pub unsafe fn as_ref(&self) -> Option<&'g T> {
1382
10.1k
        let (raw, _) = decompose_tag::<T>(self.data);
1383
10.1k
        if raw == 0 {
1384
3.96k
            None
1385
        } else {
1386
6.15k
            Some(T::deref(raw))
1387
        }
1388
10.1k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::as_ref
Line
Count
Source
1381
88.4k
    pub unsafe fn as_ref(&self) -> Option<&'g T> {
1382
88.4k
        let (raw, _) = decompose_tag::<T>(self.data);
1383
88.4k
        if raw == 0 {
1384
2.55k
            None
1385
        } else {
1386
85.8k
            Some(T::deref(raw))
1387
        }
1388
88.4k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, ()>>>::as_ref
Line
Count
Source
1381
9
    pub unsafe fn as_ref(&self) -> Option<&'g T> {
1382
9
        let (raw, _) = decompose_tag::<T>(self.data);
1383
9
        if raw == 0 {
1384
3
            None
1385
        } else {
1386
6
            Some(T::deref(raw))
1387
        }
1388
9
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::as_ref
Line
Count
Source
1381
29
    pub unsafe fn as_ref(&self) -> Option<&'g T> {
1382
29
        let (raw, _) = decompose_tag::<T>(self.data);
1383
29
        if raw == 0 {
1384
4
            None
1385
        } else {
1386
25
            Some(T::deref(raw))
1387
        }
1388
29
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::as_ref
Line
Count
Source
1381
1.25k
    pub unsafe fn as_ref(&self) -> Option<&'g T> {
1382
1.25k
        let (raw, _) = decompose_tag::<T>(self.data);
1383
1.25k
        if raw == 0 {
1384
183
            None
1385
        } else {
1386
1.07k
            Some(T::deref(raw))
1387
        }
1388
1.25k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<alloc::string::String, alloc::boxed::Box<i32>>>>::as_ref
Line
Count
Source
1381
1
    pub unsafe fn as_ref(&self) -> Option<&'g T> {
1382
1
        let (raw, _) = decompose_tag::<T>(self.data);
1383
1
        if raw == 0 {
1384
1
            None
1385
        } else {
1386
0
            Some(T::deref(raw))
1387
        }
1388
1
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<i64>>>::as_ref
Line
Count
Source
1381
7.76M
    pub unsafe fn as_ref(&self) -> Option<&'g T> {
1382
7.76M
        let (raw, _) = decompose_tag::<T>(self.data);
1383
7.76M
        if raw == 0 {
1384
4.71M
            None
1385
        } else {
1386
3.04M
            Some(T::deref(raw))
1387
        }
1388
7.76M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::as_ref
Line
Count
Source
1381
1.95M
    pub unsafe fn as_ref(&self) -> Option<&'g T> {
1382
1.95M
        let (raw, _) = decompose_tag::<T>(self.data);
1383
1.95M
        if raw == 0 {
1384
1.96M
            None
1385
        } else {
1386
18.4E
            Some(T::deref(raw))
1387
        }
1388
1.95M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::as_ref
Line
Count
Source
1381
10.2M
    pub unsafe fn as_ref(&self) -> Option<&'g T> {
1382
10.2M
        let (raw, _) = decompose_tag::<T>(self.data);
1383
10.2M
        if raw == 0 {
1384
247k
            None
1385
        } else {
1386
10.0M
            Some(T::deref(raw))
1387
        }
1388
10.2M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::as_ref
Line
Count
Source
1381
3.75M
    pub unsafe fn as_ref(&self) -> Option<&'g T> {
1382
3.75M
        let (raw, _) = decompose_tag::<T>(self.data);
1383
3.75M
        if raw == 0 {
1384
3.58M
            None
1385
        } else {
1386
168k
            Some(T::deref(raw))
1387
        }
1388
3.75M
    }
1389
1390
    /// Takes ownership of the pointee.
1391
    ///
1392
    /// # Panics
1393
    ///
1394
    /// Panics if this pointer is null, but only in debug mode.
1395
    ///
1396
    /// # Safety
1397
    ///
1398
    /// This method may be called only if the pointer is valid and nobody else is holding a
1399
    /// reference to the same object.
1400
    ///
1401
    /// # Examples
1402
    ///
1403
    /// ```
1404
    /// use crossbeam_epoch::{self as epoch, Atomic};
1405
    /// use std::sync::atomic::Ordering::SeqCst;
1406
    ///
1407
    /// let a = Atomic::new(1234);
1408
    /// unsafe {
1409
    ///     let guard = &epoch::unprotected();
1410
    ///     let p = a.load(SeqCst, guard);
1411
    ///     drop(p.into_owned());
1412
    /// }
1413
    /// ```
1414
3.79M
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
3.83M
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
3.79M
        Owned::from_usize(self.data)
1417
3.79M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::into_owned
Line
Count
Source
1414
133
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
133
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
133
        Owned::from_usize(self.data)
1417
133
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::internal::Local>>::into_owned
Line
Count
Source
1414
70
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
70
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
70
        Owned::from_usize(self.data)
1417
70
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<injector::destructors::Elem>>>::into_owned
Line
Count
Source
1414
8
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
8
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
8
        Owned::from_usize(self.data)
1417
8
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>>>::into_owned
Line
Count
Source
1414
13
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
13
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
12
        Owned::from_usize(self.data)
1417
12
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>>>::into_owned
Line
Count
Source
1414
1
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
1
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
1
        Owned::from_usize(self.data)
1417
1
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>>>::into_owned
Line
Count
Source
1414
2
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
2
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
2
        Owned::from_usize(self.data)
1417
2
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::into_owned
Line
Count
Source
1414
16
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
16
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
16
        Owned::from_usize(self.data)
1417
16
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>>>::into_owned
Line
Count
Source
1414
33
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
33
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
34
        Owned::from_usize(self.data)
1417
34
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<fifo::destructors::Elem>>>::into_owned
Line
Count
Source
1414
19
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
19
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
19
        Owned::from_usize(self.data)
1417
19
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>>>::into_owned
Line
Count
Source
1414
22
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
22
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
22
        Owned::from_usize(self.data)
1417
22
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<usize>>>::into_owned
Line
Count
Source
1414
29
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
28
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
30
        Owned::from_usize(self.data)
1417
30
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<alloc::boxed::Box<usize>>>>::into_owned
Line
Count
Source
1414
12
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
12
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
12
        Owned::from_usize(self.data)
1417
12
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<lifo::destructors::Elem>>>::into_owned
Line
Count
Source
1414
19
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
19
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
19
        Owned::from_usize(self.data)
1417
19
    }
<crossbeam_epoch::atomic::Shared<crossbeam_deque::deque::Buffer<i32>>>::into_owned
Line
Count
Source
1414
2
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
2
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
2
        Owned::from_usize(self.data)
1417
2
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>>>::into_owned
Line
Count
Source
1414
64.5k
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
64.5k
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
64.6k
        Owned::from_usize(self.data)
1417
64.6k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::into_owned
Line
Count
Source
1414
8.19k
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
8.19k
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
8.19k
        Owned::from_usize(self.data)
1417
8.19k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>>>::into_owned
Line
Count
Source
1414
5
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
5
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
5
        Owned::from_usize(self.data)
1417
5
    }
<crossbeam_epoch::atomic::Shared<alloc::vec::Vec<crossbeam_epoch::collector::tests::drop_array::Elem>>>::into_owned
Line
Count
Source
1414
1
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
1
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
1
        Owned::from_usize(self.data)
1417
1
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::collector::tests::count_drops::Elem>>::into_owned
Line
Count
Source
1414
100k
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
100k
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
100k
        Owned::from_usize(self.data)
1417
100k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::internal::Local>>::into_owned
Line
Count
Source
1414
65
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
65
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
65
        Owned::from_usize(self.data)
1417
65
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::collector::tests::stress::Elem>>::into_owned
Line
Count
Source
1414
696k
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
701k
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
734k
        Owned::from_usize(self.data)
1417
734k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<i64>>>::into_owned
Line
Count
Source
1414
2.73M
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
2.76M
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
2.69M
        Owned::from_usize(self.data)
1417
2.69M
    }
<crossbeam_epoch::atomic::Shared<i32>>::into_owned
Line
Count
Source
1414
190k
    pub unsafe fn into_owned(self) -> Owned<T> {
1415
198k
        debug_assert!(!self.is_null(), "converting a null `Shared` into `Owned`");
1416
190k
        Owned::from_usize(self.data)
1417
190k
    }
1418
1419
    /// Returns the tag stored within the pointer.
1420
    ///
1421
    /// # Examples
1422
    ///
1423
    /// ```
1424
    /// use crossbeam_epoch::{self as epoch, Atomic, Owned};
1425
    /// use std::sync::atomic::Ordering::SeqCst;
1426
    ///
1427
    /// let a = Atomic::<u64>::from(Owned::new(0u64).with_tag(2));
1428
    /// let guard = &epoch::pin();
1429
    /// let p = a.load(SeqCst, guard);
1430
    /// assert_eq!(p.tag(), 2);
1431
    /// ```
1432
    #[allow(clippy::trivially_copy_pass_by_ref)]
1433
10.9M
    pub fn tag(&self) -> usize {
1434
10.9M
        let (_, tag) = decompose_tag::<T>(self.data);
1435
10.9M
        tag
1436
10.9M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::tag
Line
Count
Source
1433
710
    pub fn tag(&self) -> usize {
1434
710
        let (_, tag) = decompose_tag::<T>(self.data);
1435
710
        tag
1436
710
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::tag
Line
Count
Source
1433
86.6k
    pub fn tag(&self) -> usize {
1434
86.6k
        let (_, tag) = decompose_tag::<T>(self.data);
1435
86.6k
        tag
1436
86.6k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, ()>>>::tag
Line
Count
Source
1433
8
    pub fn tag(&self) -> usize {
1434
8
        let (_, tag) = decompose_tag::<T>(self.data);
1435
8
        tag
1436
8
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::tag
Line
Count
Source
1433
1.85k
    pub fn tag(&self) -> usize {
1434
1.85k
        let (_, tag) = decompose_tag::<T>(self.data);
1435
1.85k
        tag
1436
1.85k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::tag
Line
Count
Source
1433
36
    pub fn tag(&self) -> usize {
1434
36
        let (_, tag) = decompose_tag::<T>(self.data);
1435
36
        tag
1436
36
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::tag
Line
Count
Source
1433
10.8M
    pub fn tag(&self) -> usize {
1434
10.8M
        let (_, tag) = decompose_tag::<T>(self.data);
1435
10.8M
        tag
1436
10.8M
    }
1437
1438
    /// Returns the same pointer, but tagged with `tag`. `tag` is truncated to be fit into the
1439
    /// unused bits of the pointer to `T`.
1440
    ///
1441
    /// # Examples
1442
    ///
1443
    /// ```
1444
    /// use crossbeam_epoch::{self as epoch, Atomic};
1445
    /// use std::sync::atomic::Ordering::SeqCst;
1446
    ///
1447
    /// let a = Atomic::new(0u64);
1448
    /// let guard = &epoch::pin();
1449
    /// let p1 = a.load(SeqCst, guard);
1450
    /// let p2 = p1.with_tag(2);
1451
    ///
1452
    /// assert_eq!(p1.tag(), 0);
1453
    /// assert_eq!(p2.tag(), 2);
1454
    /// assert_eq!(p1.as_raw(), p2.as_raw());
1455
    /// ```
1456
    #[allow(clippy::trivially_copy_pass_by_ref)]
1457
8.31k
    pub fn with_tag(&self, tag: usize) -> Shared<'g, T> {
1458
8.31k
        unsafe { Self::from_usize(compose_tag::<T>(self.data, tag)) }
1459
8.31k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::with_tag
Line
Count
Source
1457
5
    pub fn with_tag(&self, tag: usize) -> Shared<'g, T> {
1458
5
        unsafe { Self::from_usize(compose_tag::<T>(self.data, tag)) }
1459
5
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::with_tag
Line
Count
Source
1457
99
    pub fn with_tag(&self, tag: usize) -> Shared<'g, T> {
1458
99
        unsafe { Self::from_usize(compose_tag::<T>(self.data, tag)) }
1459
99
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::with_tag
Line
Count
Source
1457
1
    pub fn with_tag(&self, tag: usize) -> Shared<'g, T> {
1458
1
        unsafe { Self::from_usize(compose_tag::<T>(self.data, tag)) }
1459
1
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>>>::with_tag
Line
Count
Source
1457
64
    pub fn with_tag(&self, tag: usize) -> Shared<'g, T> {
1458
64
        unsafe { Self::from_usize(compose_tag::<T>(self.data, tag)) }
1459
64
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry>>::with_tag
Line
Count
Source
1457
8.14k
    pub fn with_tag(&self, tag: usize) -> Shared<'g, T> {
1458
8.14k
        unsafe { Self::from_usize(compose_tag::<T>(self.data, tag)) }
1459
8.14k
    }
<crossbeam_epoch::atomic::Shared<i8>>::with_tag
Line
Count
Source
1457
1
    pub fn with_tag(&self, tag: usize) -> Shared<'g, T> {
1458
1
        unsafe { Self::from_usize(compose_tag::<T>(self.data, tag)) }
1459
1
    }
<crossbeam_epoch::atomic::Shared<i64>>::with_tag
Line
Count
Source
1457
1
    pub fn with_tag(&self, tag: usize) -> Shared<'g, T> {
1458
1
        unsafe { Self::from_usize(compose_tag::<T>(self.data, tag)) }
1459
1
    }
1460
}
1461
1462
impl<T> From<*const T> for Shared<'_, T> {
1463
    /// Returns a new pointer pointing to `raw`.
1464
    ///
1465
    /// # Panics
1466
    ///
1467
    /// Panics if `raw` is not properly aligned.
1468
    ///
1469
    /// # Examples
1470
    ///
1471
    /// ```
1472
    /// use crossbeam_epoch::Shared;
1473
    ///
1474
    /// let p = Shared::from(Box::into_raw(Box::new(1234)) as *const _);
1475
    /// assert!(!p.is_null());
1476
    /// ```
1477
16.6k
    fn from(raw: *const T) -> Self {
1478
16.6k
        let raw = raw as usize;
1479
16.6k
        ensure_aligned::<T>(raw);
1480
16.6k
        unsafe { Self::from_usize(raw) }
1481
16.6k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>> as core::convert::From<*const crossbeam_skiplist::base::Node<i32, i32>>>::from
Line
Count
Source
1477
25
    fn from(raw: *const T) -> Self {
1478
25
        let raw = raw as usize;
1479
25
        ensure_aligned::<T>(raw);
1480
25
        unsafe { Self::from_usize(raw) }
1481
25
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::internal::Local> as core::convert::From<*const crossbeam_epoch::internal::Local>>::from
Line
Count
Source
1477
99
    fn from(raw: *const T) -> Self {
1478
99
        let raw = raw as usize;
1479
99
        ensure_aligned::<T>(raw);
1480
99
        unsafe { Self::from_usize(raw) }
1481
99
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry> as core::convert::From<*const crossbeam_epoch::sync::list::Entry>>::from
Line
Count
Source
1477
146
    fn from(raw: *const T) -> Self {
1478
146
        let raw = raw as usize;
1479
146
        ensure_aligned::<T>(raw);
1480
146
        unsafe { Self::from_usize(raw) }
1481
146
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, ()>> as core::convert::From<*const crossbeam_skiplist::base::Node<i32, ()>>>::from
Line
Count
Source
1477
3
    fn from(raw: *const T) -> Self {
1478
3
        let raw = raw as usize;
1479
3
        ensure_aligned::<T>(raw);
1480
3
        unsafe { Self::from_usize(raw) }
1481
3
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>> as core::convert::From<*const crossbeam_skiplist::base::Node<base::drops::Key, base::drops::Value>>>::from
Line
Count
Source
1477
8
    fn from(raw: *const T) -> Self {
1478
8
        let raw = raw as usize;
1479
8
        ensure_aligned::<T>(raw);
1480
8
        unsafe { Self::from_usize(raw) }
1481
8
    }
<crossbeam_epoch::atomic::Shared<crossbeam_skiplist::base::Node<i32, i32>> as core::convert::From<*const crossbeam_skiplist::base::Node<i32, i32>>>::from
Line
Count
Source
1477
170
    fn from(raw: *const T) -> Self {
1478
170
        let raw = raw as usize;
1479
170
        ensure_aligned::<T>(raw);
1480
170
        unsafe { Self::from_usize(raw) }
1481
170
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::list::Entry> as core::convert::From<*const crossbeam_epoch::sync::list::Entry>>::from
Line
Count
Source
1477
16.1k
    fn from(raw: *const T) -> Self {
1478
16.1k
        let raw = raw as usize;
1479
16.1k
        ensure_aligned::<T>(raw);
1480
16.1k
        unsafe { Self::from_usize(raw) }
1481
16.1k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::internal::Local> as core::convert::From<*const crossbeam_epoch::internal::Local>>::from
Line
Count
Source
1477
67
    fn from(raw: *const T) -> Self {
1478
67
        let raw = raw as usize;
1479
67
        ensure_aligned::<T>(raw);
1480
67
        unsafe { Self::from_usize(raw) }
1481
67
    }
1482
}
1483
1484
impl<'g, T: ?Sized + Pointable> PartialEq<Shared<'g, T>> for Shared<'g, T> {
1485
2.97M
    fn eq(&self, other: &Self) -> bool {
1486
2.97M
        self.data == other.data
1487
2.97M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>> as core::cmp::PartialEq>::eq
Line
Count
Source
1485
167
    fn eq(&self, other: &Self) -> bool {
1486
167
        self.data == other.data
1487
167
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::internal::SealedBag>> as core::cmp::PartialEq>::eq
Line
Count
Source
1485
64.9k
    fn eq(&self, other: &Self) -> bool {
1486
64.9k
        self.data == other.data
1487
64.9k
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<i64>> as core::cmp::PartialEq>::eq
Line
Count
Source
1485
2.90M
    fn eq(&self, other: &Self) -> bool {
1486
2.90M
        self.data == other.data
1487
2.90M
    }
<crossbeam_epoch::atomic::Shared<crossbeam_epoch::sync::queue::Node<crossbeam_epoch::sync::queue::test::push_try_pop_many_mpmc::LR>> as core::cmp::PartialEq>::eq
Line
Count
Source
1485
4
    fn eq(&self, other: &Self) -> bool {
1486
4
        self.data == other.data
1487
4
    }
1488
}
1489
1490
impl<T: ?Sized + Pointable> Eq for Shared<'_, T> {}
1491
1492
impl<'g, T: ?Sized + Pointable> PartialOrd<Shared<'g, T>> for Shared<'g, T> {
1493
0
    fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
1494
0
        self.data.partial_cmp(&other.data)
1495
0
    }
1496
}
1497
1498
impl<T: ?Sized + Pointable> Ord for Shared<'_, T> {
1499
0
    fn cmp(&self, other: &Self) -> cmp::Ordering {
1500
0
        self.data.cmp(&other.data)
1501
0
    }
1502
}
1503
1504
impl<T: ?Sized + Pointable> fmt::Debug for Shared<'_, T> {
1505
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1506
0
        let (raw, tag) = decompose_tag::<T>(self.data);
1507
0
1508
0
        f.debug_struct("Shared")
1509
0
            .field("raw", &raw)
1510
0
            .field("tag", &tag)
1511
0
            .finish()
1512
0
    }
1513
}
1514
1515
impl<T: ?Sized + Pointable> fmt::Pointer for Shared<'_, T> {
1516
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1517
0
        fmt::Pointer::fmt(&(unsafe { self.deref() as *const _ }), f)
1518
0
    }
1519
}
1520
1521
impl<T: ?Sized + Pointable> Default for Shared<'_, T> {
1522
0
    fn default() -> Self {
1523
0
        Shared::null()
1524
0
    }
1525
}
1526
1527
#[cfg(all(test, not(loom_crossbeam)))]
1528
mod tests {
1529
    use super::Shared;
1530
1531
    #[test]
1532
1
    fn valid_tag_i8() {
crossbeam_epoch::atomic::tests::valid_tag_i8::{closure#0}
Line
Count
Source
1532
1
    fn valid_tag_i8() {
1533
1
        Shared::<i8>::null().with_tag(0);
1534
1
    }
crossbeam_epoch::atomic::tests::valid_tag_i8
Line
Count
Source
1532
1
    fn valid_tag_i8() {
1533
1
        Shared::<i8>::null().with_tag(0);
1534
1
    }
1535
1536
    #[test]
1537
1
    fn valid_tag_i64() {
1538
1
        Shared::<i64>::null().with_tag(7);
1539
1
    }
1540
1541
    #[cfg(feature = "nightly")]
1542
    #[test]
1543
    fn const_atomic_null() {
1544
        use super::Atomic;
1545
        const _: Atomic<u8> = Atomic::<u8>::null();
1546
    }
1547
}