(vm: &VirtualMachine)
| 41 | #[cfg_attr(feature = "flame-it", flame)] |
| 42 | #[inline(always)] |
| 43 | pub fn check_signals(vm: &VirtualMachine) -> PyResult<()> { |
| 44 | if vm.signal_handlers.get().is_none() { |
| 45 | return Ok(()); |
| 46 | } |
| 47 | |
| 48 | // Read-only check first: avoids cache-line invalidation on every |
| 49 | // instruction when no signal is pending (the common case). |
| 50 | if !ANY_TRIGGERED.load(Ordering::Relaxed) { |
| 51 | return Ok(()); |
| 52 | } |
| 53 | // Atomic RMW only when a signal is actually pending. |
| 54 | if !ANY_TRIGGERED.swap(false, Ordering::Acquire) { |
| 55 | return Ok(()); |
| 56 | } |
| 57 | |
| 58 | trigger_signals(vm) |
| 59 | } |
| 60 | |
| 61 | #[inline(never)] |
| 62 | #[cold] |
no test coverage detected