Struct fake_clock_svc::FakeClock
source · pub(crate) struct FakeClock<T> {
pub(crate) time: Time,
pub(crate) free_running: Option<Task<()>>,
pub(crate) pending_events: BinaryHeap<PendingEvent>,
pub(crate) registered_events: HashMap<Koid, RegisteredEvent>,
pub(crate) pending_named_deadlines: BinaryHeap<PendingDeadlineExpireEvent>,
pub(crate) ignored_deadline_ids: HashSet<DeadlineId>,
pub(crate) registered_stop_points: HashMap<StopPoint, EventPair>,
pub(crate) observer: T,
}
Expand description
The fake clock implementation.
Type parameter T
is used to observe events during testing.
The empty tuple ()
implements FakeClockObserver
and is meant to be used
for production instances.
Fields§
§time: Time
§free_running: Option<Task<()>>
§pending_events: BinaryHeap<PendingEvent>
§registered_events: HashMap<Koid, RegisteredEvent>
§pending_named_deadlines: BinaryHeap<PendingDeadlineExpireEvent>
§ignored_deadline_ids: HashSet<DeadlineId>
§registered_stop_points: HashMap<StopPoint, EventPair>
§observer: T
Implementations§
source§impl<T: FakeClockObserver> FakeClock<T>
impl<T: FakeClockObserver> FakeClock<T>
pub(crate) fn new() -> Self
pub(crate) fn is_free_running(&self) -> bool
pub(crate) fn check_events(&mut self)
sourcepub(crate) fn check_stop_point(&mut self, stop_point: &StopPoint) -> bool
pub(crate) fn check_stop_point(&mut self, stop_point: &StopPoint) -> bool
Check if a matching stop point is registered and attempts to signal the matching eventpair if one is registered. Returns true iff a match exists and signaling the event pair succeeds.
sourcepub(crate) fn check_stop_points(&mut self) -> bool
pub(crate) fn check_stop_points(&mut self) -> bool
Check if any expired stop points are registered and signal any that exist. Returns true iff at least one is expired and has been successfully signaled.
pub(crate) fn install_event( &mut self, arc_self: Arc<Mutex<FakeClock<T>>>, time: Time, event: EventPair )
pub(crate) fn reschedule_event(&mut self, time: Time, koid: Koid)
pub(crate) fn cancel_event(&mut self, koid: Koid)
sourcepub(crate) fn set_stop_point(
&mut self,
stop_point: StopPoint,
eventpair: EventPair
) -> Result<(), Status>
pub(crate) fn set_stop_point( &mut self, stop_point: StopPoint, eventpair: EventPair ) -> Result<(), Status>
Set a stop point at which to stop time and signal the provided eventpair
.
Returns ZX_ALREADY_BOUND
if an identical stop point is already registered.