Returns the first weakref in the weakref list, if any.
(&self)
| 1324 | |
| 1325 | /// Returns the first weakref in the weakref list, if any. |
| 1326 | pub(crate) fn get_weakrefs(&self) -> Option<PyObjectRef> { |
| 1327 | let wrl = self.weak_ref_list()?; |
| 1328 | let _lock = weakref_lock::lock(self as *const PyObject as usize); |
| 1329 | let head_ptr = wrl.head.load(Ordering::Relaxed); |
| 1330 | if head_ptr.is_null() { |
| 1331 | None |
| 1332 | } else { |
| 1333 | let head = unsafe { &*head_ptr }; |
| 1334 | if head.0.ref_count.safe_inc() { |
| 1335 | Some(unsafe { PyRef::from_raw(head_ptr) }.into()) |
| 1336 | } else { |
| 1337 | None |
| 1338 | } |
| 1339 | } |
| 1340 | } |
| 1341 | |
| 1342 | pub(crate) fn downgrade_with_weakref_typ_opt( |
| 1343 | &self, |
no test coverage detected