Inject `val` into the first `WaitingEvent` waiter's saved stack (innermost sync sub-frame wins) and mark it Ready; queues `val` otherwise. Shared by `push_event` and `run_push_event`. */
(&mut self, val: Val)
| 67 | |
| 68 | /* Inject `val` into the first `WaitingEvent` waiter's saved stack (innermost sync sub-frame wins) and mark it Ready; queues `val` otherwise. Shared by `push_event` and `run_push_event`. */ |
| 69 | pub fn inject_event(&mut self, val: Val) { |
| 70 | let waiter = self.scheduler.iter().enumerate() |
| 71 | .find(|(_, h)| matches!(h.state, CoroState::WaitingEvent)) |
| 72 | .map(|(i, h)| (i, h.coro)); |
| 73 | if let Some((idx, coro)) = waiter { |
| 74 | if let HeapObj::Coroutine(_, _, saved_stack, _, _, sub_frames, _) = self.heap.get_mut(coro) { |
| 75 | let target_stack = if let Some(frame) = sub_frames.last_mut() { &mut frame.stack_delta } else { saved_stack }; |
| 76 | if let Some(top) = target_stack.last_mut() { *top = val; } else { target_stack.push(val); } |
| 77 | } |
| 78 | self.scheduler[idx].state = CoroState::Ready; |
| 79 | } else { |
| 80 | self.event_queue.push(val); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /* Inject `val` into the first `WaitingHostCall` waiter and mark it Ready; false if none. Uncorrelated path for hosts/tests that don't track call ids. */ |
| 85 | pub fn inject_host_result(&mut self, val: Val) -> bool { |
no test coverage detected