pub struct VmTimeAccess { /* private fields */ }
Expand description
An individual time accessor, used to query and wait for time.
Implementations§
Source§impl VmTimeAccess
impl VmTimeAccess
Sourcepub fn host_time(&self, time: VmTime) -> Option<Instant>
pub fn host_time(&self, time: VmTime) -> Option<Instant>
Returns the host time corresponding to a guest time.
If the guest time is before the VM last resumed, then returns the time the VM last resumed.
If the VM is not running, returns None
.
Sourcepub fn get_timeout(&self) -> Option<VmTime>
pub fn get_timeout(&self) -> Option<VmTime>
Get the currently set timeout.
Sourcepub fn set_timeout(&mut self, time: VmTime)
pub fn set_timeout(&mut self, time: VmTime)
Sets the timeout poll_timeout
will return ready.
Sourcepub fn set_timeout_if_before(&mut self, time: VmTime)
pub fn set_timeout_if_before(&mut self, time: VmTime)
Sets the timeout for poll_timeout
will return ready,
but only if time
is earlier than the current timeout.
Sourcepub fn cancel_timeout(&mut self)
pub fn cancel_timeout(&mut self)
Clears the current timeout for poll_timeout
.
Sourcepub fn poll_timeout(&mut self, cx: &mut Context<'_>) -> Poll<VmTime>
pub fn poll_timeout(&mut self, cx: &mut Context<'_>) -> Poll<VmTime>
Polls the current time against the current timeout.
Returns Poll::Ready(self.now())
if the current timeout is before now.
Returns Poll::Pending
if there is no current timeout, or if the
current timeout is after now.
Although this takes &self
, note that it only stores a single waker,
meaning that if you poll this from multiple tasks concurrently, only one
task will be woken when the time elapses. Create another instance of
this type with VmTimeSource
if you need to poll this from multiple
tasks.