viceroy_lib/wiggle_abi/compute_runtime.rs
1use crate::error::Error;
2use crate::session::Session;
3use crate::wiggle_abi::fastly_compute_runtime::FastlyComputeRuntime;
4use std::sync::atomic::Ordering;
5use wiggle::GuestMemory;
6
7impl FastlyComputeRuntime for Session {
8 fn get_vcpu_ms(&mut self, _memory: &mut GuestMemory<'_>) -> Result<u64, Error> {
9 // we internally track microseconds, because our wasmtime tick length
10 // is too short for ms to work. but we want to shrink this to ms to
11 // try to minimize timing attacks.
12 Ok(self.active_cpu_time_us.load(Ordering::SeqCst) / 1000)
13 }
14}