MCPcopy Index your code
hub / github.com/RustPython/RustPython / lock

Function lock

crates/vm/src/object/core.rs:458–469  ·  view source on GitHub ↗
(addr: usize)

Source from the content-addressed store, hash-verified

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.

Callers 8

addMethod · 0.85
clearMethod · 0.85
countMethod · 0.85
get_weak_referencesMethod · 0.85
upgradeMethod · 0.85
drop_innerMethod · 0.85
get_weakrefsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected