(addr: usize)
| 456 | } |
| 457 | |
| 458 | pub(super) fn lock(addr: usize) -> WeakrefLockGuard { |
| 459 | let idx = (addr >> 4) % NUM_WEAKREF_LOCKS; |
| 460 | loop { |
| 461 | if LOCKS[idx] |
| 462 | .compare_exchange_weak(0, 1, Ordering::Acquire, Ordering::Relaxed) |
| 463 | .is_ok() |
| 464 | { |
| 465 | return WeakrefLockGuard { idx }; |
| 466 | } |
| 467 | core::hint::spin_loop(); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | /// Reset all weakref stripe locks after fork in child process. |
| 472 | /// Locks held by parent threads would cause infinite spin in the child. |
no outgoing calls
no test coverage detected