12345678910111213141516171819202122open!Coretypet={mutablelast_output:Time_ns.Span.t}letcreate()={last_output=Time_ns.Span.zero}letevent_startt~output_time?input_time()=letinput_time=matchinput_timewith(* Use 0-duration slice if no input time *)|None->output_time(* We might have queuing, each message has to start after the last finishes *)|Someinput_time->(* Avoid saying the next event starts at exactly the time of the prior send *)letafter_last=Time_ns.Span.(t.last_output+of_int_ns1)in(* This defends against multiple events output at the same time but intentionally
not against input_time>output_time since we want a downstream error for that *)Time_ns.Span.max(Time_ns.Span.minafter_lastoutput_time)input_timeint.last_output<-output_time;input_time;;