(&self)
| 121 | #[inline] |
| 122 | #[must_use] |
| 123 | pub fn safe_inc(&self) -> bool { |
| 124 | let mut old = State::from_raw(self.state.load(Ordering::Relaxed)); |
| 125 | loop { |
| 126 | if old.destructed() || old.strong() == 0 { |
| 127 | return false; |
| 128 | } |
| 129 | if (old.strong() as usize) >= STRONG { |
| 130 | refcount_overflow(); |
| 131 | } |
| 132 | let new_state = old.add_strong(1); |
| 133 | match self.state.compare_exchange_weak( |
| 134 | old.as_raw(), |
| 135 | new_state.as_raw(), |
| 136 | Ordering::Relaxed, |
| 137 | Ordering::Relaxed, |
| 138 | ) { |
| 139 | Ok(_) => return true, |
| 140 | Err(curr) => old = State::from_raw(curr), |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /// Decrement strong count. Returns true when count drops to 0. |
| 146 | #[inline] |
no test coverage detected