Get all threads' current (top) frames. Used by sys._current_frames().
(vm: &VirtualMachine)
| 1031 | |
| 1032 | /// Get all threads' current (top) frames. Used by sys._current_frames(). |
| 1033 | pub fn get_all_current_frames(vm: &VirtualMachine) -> Vec<(u64, FrameRef)> { |
| 1034 | let registry = vm.state.thread_frames.lock(); |
| 1035 | registry |
| 1036 | .iter() |
| 1037 | .filter_map(|(id, slot)| { |
| 1038 | let frames = slot.frames.lock(); |
| 1039 | // SAFETY: the owning thread can't pop while we hold the Mutex, |
| 1040 | // so the FramePtr is valid for the duration of the lock. |
| 1041 | frames |
| 1042 | .last() |
| 1043 | .map(|fp| (*id, unsafe { fp.as_ref() }.to_owned())) |
| 1044 | }) |
| 1045 | .collect() |
| 1046 | } |
| 1047 | |
| 1048 | /// Called after fork() in child process to mark all other threads as done. |
| 1049 | /// This prevents join() from hanging on threads that don't exist in the child. |