| 748 | } |
| 749 | |
| 750 | fn count(&self, obj: &PyObject) -> usize { |
| 751 | let _lock = weakref_lock::lock(obj as *const PyObject as usize); |
| 752 | let mut count = 0usize; |
| 753 | let mut current = NonNull::new(self.head.load(Ordering::Relaxed)); |
| 754 | while let Some(node) = current { |
| 755 | if unsafe { node.as_ref() }.0.ref_count.get() > 0 { |
| 756 | count += 1; |
| 757 | } |
| 758 | current = unsafe { WeakLink::pointers(node).as_ref().get_next() }; |
| 759 | } |
| 760 | count |
| 761 | } |
| 762 | |
| 763 | fn get_weak_references(&self, obj: &PyObject) -> Vec<PyRef<PyWeak>> { |
| 764 | let _lock = weakref_lock::lock(obj as *const PyObject as usize); |