wait_event

Function wait_event 

Source
pub fn wait_event<T: Bag>(
    config: &Config,
    input_handler: impl FnMut(Duration, &mut T),
) -> impl FnMut(f64, f64, &mut T) -> f64
Expand description

It computes the next wall-clock time corresponding to the next state transition of the model.

An input handler function waits for external events without exceeding the time for the next internal event. Finally, it checks that the wall-clock drift does not exceed the maximum jitter allowed (if any) and panics if it does.

§Arguments

  • config - The desired simulator configuration.
  • input_handler - The function to handle incoming external events. This function expects two arguments:
    • duration: [Duration] - Maximum duration of the time interval to wait for external events. The input handler function may return earlier if an input event is received. Note, however, that it must NOT return after, as it would result in an incorrect real-time implementation.
    • input_ports: &mut T - Mutable reference to the input ports of the top-most model under simulation.

§Returns

A closure that takes the current and next virtual time and a mutable reference to the bag and returns the next virtual time.

§Example

xdevs::simulator::std::wait_event(0., 1., Some(Duration::from_millis(50)), some_input_handler);