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

Method awaited_by_discard

crates/stdlib/src/_asyncio.rs:748–765  ·  view source on GitHub ↗

Discard waiter from fut_awaited_by with single-object optimization

(&self, waiter: &PyObject, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

746
747 /// Discard waiter from fut_awaited_by with single-object optimization
748 fn awaited_by_discard(&self, waiter: &PyObject, vm: &VirtualMachine) -> PyResult<()> {
749 let mut awaited_by = self.fut_awaited_by.write();
750 if awaited_by.is_none() {
751 return Ok(());
752 }
753
754 let obj = awaited_by.as_ref().unwrap();
755 if !self.fut_awaited_by_is_set.load(Ordering::Relaxed) {
756 // Single object - check if it matches
757 if obj.is(waiter) {
758 *awaited_by = None;
759 }
760 } else {
761 // It's a Set - use discard
762 vm.call_method(obj, "discard", (waiter.to_owned(),))?;
763 }
764 Ok(())
765 }
766
767 #[pymethod]
768 fn __await__(zelf: PyRef<Self>, _vm: &VirtualMachine) -> PyResult<PyFutureIter> {

Callers 1

Calls 8

isMethod · 0.80
writeMethod · 0.45
is_noneMethod · 0.45
unwrapMethod · 0.45
as_refMethod · 0.45
loadMethod · 0.45
call_methodMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected