MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / inject_event

Method inject_event

compiler/src/modules/vm/init.rs:69–82  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 {

Callers 2

push_eventMethod · 0.80
run_push_eventFunction · 0.80

Calls 3

get_mutMethod · 0.80
pushMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected