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

Method call_sleep

compiler/src/modules/vm/builtins/async_ops.rs:432–445  ·  view source on GitHub ↗

Suspend until `s` real seconds elapse. */

(&mut self)

Source from the content-addressed store, hash-verified

430
431 /* Suspend until `s` real seconds elapse. */
432 pub fn call_sleep(&mut self) -> Result<(), VmErr> {
433 let n = self.pop()?;
434 let secs: f64 = if n.is_int() { n.as_int() as f64 }
435 else if n.is_float() { n.as_float() }
436 else if n.is_bool() { n.as_bool() as i64 as f64 }
437 else { 0.0 };
438 let secs = if secs < 0.0 { 0.0 } else { secs };
439 let until = self.now_ns().saturating_add((secs * 1_000_000_000.0) as u64);
440 self.pending.sleep_until_ns = Some(until);
441 // Push None as the yield value; the scheduler ignores it.
442 self.push(Val::none());
443 self.yielded = true;
444 Ok(())
445 }
446
447 /* `gather(*coros)`, single-driver: pushes all targets, parks the outer in `WaitingForChildren` with `WaitKind::Gather`, and yields. Wake-loop builds the result list (or raises the first child error). */
448 pub fn call_gather(&mut self, argc: u16) -> Result<(), VmErr> {

Callers 1

dispatch_nativeMethod · 0.80

Calls 9

is_intMethod · 0.80
as_intMethod · 0.80
is_floatMethod · 0.80
as_floatMethod · 0.80
is_boolMethod · 0.80
as_boolMethod · 0.80
now_nsMethod · 0.80
pushMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected