Suspend until `s` real seconds elapse. */
(&mut self)
| 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> { |